LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

See if specified Time from time zone is during DST. Anyone have function?

Solved!
Go to solution

Wanted to check and see if this is alredy done.

 

With time in UTC, and the users Time Zone, does anyone have a good function already created to see if its in DST.  i know that its the second Sunday in March is forward, and First Sunday in November is back.  

 

or maybe CVI has one built in I can't find.  Either way, it wouldn't be hard to do but don't know a good way to figure out certain weekday of a month.

0 Kudos
Message 1 of 5
(3,811 Views)

Check out the ANSI C functions time() and localtime() and the corresponding tm structure, which contains a flag int tm_isdst.

 

JR

0 Kudos
Message 2 of 5
(3,800 Views)

I understand those functions, but I can't seem to figure out if a certain time in the past isDST.  for example we are currently in DST but my test was from nonDST

 

time give me current time and if its DST

mktime - I tell it if its DST (which is opposite of what I want)

gmtime - Could figure out gmtime but their rules on DST are different than where my user might be.

 

So seems like I should create a progrma manually by figuring if its in the time frame.

0 Kudos
Message 3 of 5
(3,797 Views)
Solution
Accepted by topic author ngay528

According to Microsoft's help description for their mktime() function, you can fill in a tm structure for the date you wish to test, but setting the tm_isdst field to a negative value first. This will force the function to calculate the correct value for the field - in other words it will then tell you if DST was in effect for that date.

 

I'm not sure if this is standard ANSI behaviour for this function, but it should be easy enough for you to test it out.

 

JR

Message 4 of 5
(3,770 Views)
Good job jr, thanks for the research, I knew there had to be an easy way to figure it out ...... now just to implement it within graphs without CVI screwing it up with absolute offset 😕
0 Kudos
Message 5 of 5
(3,753 Views)