LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

localtime and tm_isdst

Using CVI 2009 SP1 I see that I can use localtime() to see if a specified GMT converted into time zone is during DST.

But I noticed that the tm_isdst field is updated in the right way only if I set it to -1 before calling localtime().

 

This behaviour is similar to the one described in the Microsoft's help for time functions:

 


When specifying a tm structure time, set the tm_isdst field to:

 

  • Zero (0) to indicate that standard time is in effect.
  • A value greater than 0 to indicate that daylight saving time is in effect.
  • A value less than zero to have the C run-time library code compute whether standard time or daylight saving time is in effect.

 


 

Has the CVI localtime() the same behaviour?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 4
(6,024 Views)

I did other tests, and I was wrong:

localtime() sets tm_isdst only if at the boot time the MS Windows option "Automatically adjust clock for daylight saving changes" is enabled (even if you disable it after the boot).

If this option is disabled at boot time, localtime always return tm_isdst = 0 (DST not in effect).

Calling mktime() after having set tm_isdst = -1 doesn't help (different behaviour from the one described in the Microsoft's KB).

 

I'm afraid the only successful way is the one described here (http://forums.ni.com/t5/LabWindows-CVI/See-if-specified-Time-from-time-zone-is-during-DST-Anyone-hav...

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 2 of 4
(6,017 Views)

Dear Vix,

 

I suggest you to visit the following webpage:

http://weseetips.com/2008/05/28/how-to-convert-local-system-time-to-utc-or-gmt/

 

Regards,

MarcoMar

National Instruments Italy
0 Kudos
Message 3 of 4
(5,988 Views)

The only successful way when the option "Automatically adjust clock for daylight saving changes" is disabled is the one described by Colin in this post

 

 


 

cdk 52 wrote:

 

You can use Windows SDK functions to accomplish this (refer to the SDK Help):

  • Call GetSystemTime() to get the current (UTC / GMT) time information in a SYSTEMTIME struct
  • Call SystemTimeToTzSpecificLocalTime() to convert to local time, adjusted for Daylight Saving if required
  • To check whether Daylight Saving Time is in force, call GetTimeZoneInformation()
  • Use GetTimeFormat() / GetDateFormat() to create a string representation of the current time

Note that CVI's Utility library provides a GetSystemTime() function; check the CVI Help for precautions you may need to take.

 


 

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 4 of 4
(5,962 Views)