LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI of the Day (8/21/09)

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?

Message 1 of 11
(4,699 Views)

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.

Message Edited by Ben on 08-21-2009 12:39 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 11
(4,695 Views)

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
Download All
Message 3 of 11
(4,675 Views)

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.

Message Edited by Ben on 08-21-2009 01:52 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 11
(4,654 Views)
Nice, but I don't think that meets Ben's rules.  Turn your Time Now into a Tiemstamp control and play with times and dates around the spring and fall daylight savings times changes.  (2am March 8, 2009 and 2 am November 1, 2009 for example)  The new time will be 24 hours after the input time, but not 1 Day (which would be 23 hours later in the spring and 25 hours later in the fall).
Message 5 of 11
(4,649 Views)

You could add or subtract an hour based on the DST value in the date/time record.

Message Edited by Ravens Fan on 08-21-2009 03:14 PM
Message 6 of 11
(4,636 Views)

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.

Message Edited by Ben on 08-21-2009 02:24 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 11
(4,627 Views)

Thanks.

 

Why did you only check through 2024?  Is that your retirement date?Smiley Very Happy 

 

0 Kudos
Message 8 of 11
(4,611 Views)

Ravens Fan wrote:

Thanks.

 

Why did you only check through 2024?  Is that your retirement date?Smiley Very Happy 

 


 

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 11
(4,603 Views)
Good Year!
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 10 of 11
(4,594 Views)