Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Real Time Target Time - Daylight Savings Not Shown

Solved!
Go to solution

So my goal is to have the host timezone, and time settings pushed down to the RT controller on first connection, if the time varies by more than some amount of time, say 5 minutes.  So I found some code on how to detect the timezone that the host PC is in, and I have the Set Time function for the RT target.  Attached is the VI which will set the time of the host down to the time on the RT, then read back the time on the RT, compare it to the host and look at the difference which in my case is on the order of a second difference or so.  All appears to be working well.

 

That is until I go and check the time in MAX.  When I look at the Time Settings on the controller I see the time is one hour off, the timezone is correct, and adjust for daylight savings is turned off, but it is on for my host.  Is this expected?  Is my controller actually compensating for daylight savings?  How can I check the daylight savings setting programatically, and how can I set it programatically if I am not already?  I'm just concerned that in 6 months my time will be off by an hour.  Thanks.

 

RT Time.png

By the way this is on a cDAQ-9136 Linux RT OS, LabVIEW 2017 SP1 32-bit, host is Windows 7 x64.

0 Kudos
Message 1 of 5
(2,511 Views)

I hate timezones. Yes, it might be off in 6 months. You seem to have specified the timezone as "GMT + x" which does not undergo daylight savings. If you specified a city, like America/Los_Angeles, it might do the right thing.

 

I say "might"  because

Note  If your target does not support automatic daylight saving time adjustment, specify the GMT time equivalent for your location instead of the actual time zone. Otherwise, data timestamps may be inaccurate.

http://zone.ni.com/reference/en-XX/help/373107H-01/nisyscfg/set_time/

0 Kudos
Message 2 of 5
(2,480 Views)

Well my target does support daylight savings, and I can set this manually but I'd rather it be automatic.  I guess what I'd like to ask is, how can I set daylight savings on my target programatically?  If the only way is by specifying the city in that time zone, that observes daylight savings (instead of specifying GMT+/-) then making this be more flexible will be a problem. 

 

Again the goal of this (which I thought would be a common request) is to just take whatever time settings my host has, and push them down to the controller.  If there is an easier way to do this I'd like to know it.  And while this will could be ran periodically, I don't feel like having to require a constant connection to my host, just so that every 6 months, the time is updated to match the host.

0 Kudos
Message 3 of 5
(2,458 Views)
Solution
Accepted by topic author Hooovahh

Okay attached is a second version.  What this does is look at what time zone you are in, and if you use DST, and if you do it specifies a city in that timezone that uses DST.  I only added the main 5 US time zones that observe DST.  Just tested it and it seems to work.  You are right that not all controllers support this, and some require a restart after the update but my Linux RT one does not.

Message 4 of 5
(2,455 Views)

Okay I'm back for more a couple years later now that I decided to implement this.  I do however have an issue.  On my Windows computer I have day light savings time checked.  But because of the time of year we aren't actually observing day light savings time.  So when you use the Seconds to Date/Time and read the DST output it is 0.  But what I actually want to know is if the system I am on observes day light savings time automatically.

 

So does anyone know how to query this information on Windows?  I might be posting elsewhere because this post has a solution already and might not get much attention.

 

EDIT: I'm dumb.  Just change the month to a month that has DST, then see if the value is set.

0 Kudos
Message 5 of 5
(1,537 Views)