08-21-2009 12:27 PM
Inspired by a recent thread, it seems like a good day to explore how LV keeps track of time. The function for today is "Date/Time to Seconds".
You can find several interesting discussions on time by searching the forum (one of the most important LV skills you should master).
Why the heck 1904? Is there a major problem looming in 2100, the Y2.1K bug? Perhaps there is an earlier problem, when does the current system fail?
Can you pass timestamps to Excel and get the right date/time to show up?
08-21-2009 12:38 PM - edited 08-21-2009 12:39 PM
Darin.K wrote:Inspired by a recent thread, it seems like a good day to explore how LV keeps track of time. The function for today is "Date/Time to Seconds".
You can find several interesting discussions on time by searching the forum (one of the most important LV skills you should master).
Why the heck 1904? Is there a major problem looming in 2100, the Y2.1K bug? Perhaps there is an earlier problem, when does the current system fail?
Can you pass timestamps to Excel and get the right date/time to show up?
For Mega-Kudos*
Develop and post a VI for use by the community that will;
Given the current time return the of the time that represents the same time on the next calendar day.
To qualify the VI should;
Handle daylight savings time.
If the time today does not exist on the next day, it should coerce the time to following hour.
Notes:
Not all days have 24 hours. One has 23 and another has 25.
US Congress can change its time and time it minds** so the code can NOT assume DST will be the same in the future as it is now.
Did I miss any other rules or "gotchas"?
Ben
* Well maybe not Mega-Kudos but at least deca-Kudos.
** No that is worded the way I intended.
08-21-2009 01:22 PM - edited 08-21-2009 01:22 PM
I am sure I am missing something for it to be worth Mega-kudos. Probably the part about predicting the decisions of the US Congress...
08-21-2009 01:50 PM - edited 08-21-2009 01:52 PM
paulmw wrote:I am sure I am missing something for it to be worth Mega-kudos. Probably the part about predicting the decisions of the US Congress...
Message Edited by paulmw on 08-21-2009 01:22 PM
I was excited when I saw your solution thinking "maybe the day units is smart enough to adapt to DST.
According to my quick test if you run your VI at
11:00:00 PM on 3/7/2009
it will return the time
12:00:00 AM 3/9/2009
So if we used that aproach to schedule a backup operation, we would have no backups for the 8th.
If the date was
12:03:00 AM 11/1/2009 the returned time will be the same day.
So one day of the year does not have a backup file and the other day we have two backups run.
Ben
PS I gave you 0.1 deca-Kudos because you made me think. If the community deems your solution good, I'll make sure you get the rest.
08-21-2009 01:58 PM
08-21-2009 02:13 PM - edited 08-21-2009 02:14 PM
You could add or subtract an hour based on the DST value in the date/time record.
08-21-2009 02:24 PM - edited 08-21-2009 02:24 PM
Nice solution Ravens Fan!
It passed my tester through 2024.
It would have been nice if the Forum (and you) were around when I first faced this issue.
Ben
PS Deca-Kudos will delivered over time.
08-21-2009 02:40 PM
Thanks.
Why did you only check through 2024? Is that your retirement date?
08-21-2009 02:51 PM
Ravens Fan wrote:Thanks.
Why did you only check through 2024? Is that your retirement date?
If that was the case I would have only tested it through 2017.
No, i was watching the dates increment and thought when it passed 2012 that would cover the Myan calendar and by the time I hit the stop button it was 2024. I did not notice any trogladites durring the test by the way.
Ben
08-21-2009 03:03 PM