A function for every minute of the day...
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
So what did you do?
private static readonly O932 = new System.DateTime ( 9 , 32 , 00 ) ;
...
private bool IsBefore932()
{
return ( System.DateTime.Now.TimeOfDay <= O932 ) ;
}(Or something like that, only better.)
-
So what did you do?
private static readonly O932 = new System.DateTime ( 9 , 32 , 00 ) ;
...
private bool IsBefore932()
{
return ( System.DateTime.Now.TimeOfDay <= O932 ) ;
}(Or something like that, only better.)
Compiler error! Wait… is that a zero or the letter O?
So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
-
Compiler error! Wait… is that a zero or the letter O?
So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
The letter O, of course. :-D
-
So what did you do?
private static readonly O932 = new System.DateTime ( 9 , 32 , 00 ) ;
...
private bool IsBefore932()
{
return ( System.DateTime.Now.TimeOfDay <= O932 ) ;
}(Or something like that, only better.)
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
Gems like this is the reason I don't buy commercial ready-to-use components or libraries unless I can see the source code myself. :doh:
So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
At least... does its job! :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
I would love to see the specs for that particular case.
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
I think they call that method every morning. :)
I'd been called 'ugly', 'pug ugly', 'fugly', 'pug fugly' but never 'ugly ugly'. - Moe Szyslak
-
I would love to see the specs for that particular case.
cheers, Chris Maunder
CodeProject.com : C++ MVP
It's part of a real-time application with tasks that are interdependent with tasks performed by many other apps running over several networks. 9:32 was the start time for a group of tasks it needed to do. It's actually an upgrade from the now deprecated function IsBefore928() :-) We know the maximum time each task takes to complete, so we can use cutoff times as a simple way to coordinate tasks between different machines on different networks without them having to know anything about each other. A settings file for the task start/stop times would be better. But to be fair, as a couple of guys have pointed out here, it does what it is supposed to!
-
The letter O, of course. :-D
-
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
Yea, alot of unneccesary code there.
Mark Brock Click here to view my blog
-
O0O0O0
O0O0O0... huh, I thought it was. I know I meant it to be, but the
pre
they look the same. What kind of second-rate joint is this? I'm going to the suggestion forum next. -
O0O0O0
O0O0O0... huh, I thought it was. I know I meant it to be, but the
pre
they look the same. What kind of second-rate joint is this? I'm going to the suggestion forum next. -
Found this little gem in one of our apps at work ...
// A method to check if current time is before 09:32am. private bool IsBefore932() { if (Clock.Now.Hour < 9) { return true; } else if (Clock.Now.Hour == 9) { if (Clock.Now.Minute < 32) { return true; } else { return false; } } else { return false; } }
I hope you have unit tests with 100% code coverage for each one of those methods.
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon