|
-
Feb 17th, 2006, 04:01 PM
#1
Thread Starter
PowerPoster
algorithm help
I am just not the usual me today and it sucks!!! 
I need some help.
We have an object. it has a datetime property.
What I want to do is to execute a certain condition IF TRUE.
condition:
if the object datetime hour == current hour (but should fail if the minute given as input is < current minute) or the hour given is > current hour and minute input can be of any value as long as the hour given is > current hour.
does that makes sense? lol
how can I make that into a conditional IF statement?
-
Feb 17th, 2006, 04:11 PM
#2
Thread Starter
PowerPoster
Re: algorithm help
actually I think I got it after re-reading this thread LOL
but still I would like your suggestions!
-
Feb 18th, 2006, 03:41 AM
#3
Re: algorithm help
Correct me if I'm wrong but basically you want to test whether the time portion of a DateTime object is later than the current time of day, yes? If so you can use the fact that TimeSpan objects support the standard comparison operators.
Code:
TimeSpan inputTime = inputDate.TimeOfDay;
TimeSpan currentTime = DateTime.Now.TimeOfDay;
if (inputTime > currentTime)
MessageBox.Show("The selected time is after the current time.");
else if (inputTime < currentTime)
MessageBox.Show("The selected time is before the current time.");
else
MessageBox.Show("The selected time is the current time.");
-
Feb 18th, 2006, 07:40 AM
#4
Thread Starter
PowerPoster
Re: algorithm help
well that is partially correct but I want to make sure that it does not "clash" with another time object but I have it sorted now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|