Jump to content

How to set windows date and time properties


Recommended Posts

QUOTE(TiT @ Dec 19 2007, 05:49 AM)

Windows API: Get/SetTimeZoneInformation http://msdn2.microsoft.com/en-us/library/ms724944(VS.85).aspx' target="_blank">(link)

But it's not a trivial API and you have to do potentially some extra stuff such as getting a system Time structure correctly filled, etc. The one thing you can't avoid is that you need to adjust the application privilege before you can change the system time information. Because of that it would be best to write an external code DLL that does this all in a neat and proper way and import this as a single function into LabVIEW.

In the discription to the TIME_ZONE_INFORMATION structure it states that to disable daylight saving time you need to set the month value in both date structures to 0, among a few other conditions.

Rolf Kalbermatter

Link to comment

QUOTE(rolfk @ Dec 19 2007, 12:18 PM)

Windows API: Get/SetTimeZoneInformation http://msdn2.microsoft.com/en-us/library/ms724944%28VS.85%29.aspx' target="_blank">(link)

But it's not a trivial API and you have to do potentially some extra stuff such as getting a system Time structure correctly filled, etc. The one thing you can't avoid is that you need to adjust the application privilege before you can change the system time information. Because of that it would be best to write an external code DLL that does this all in a neat and proper way and import this as a single function into LabVIEW.

In the discription to the TIME_ZONE_INFORMATION structure it states that to disable daylight saving time you need to set the month value in both date structures to 0, among a few other conditions.

Rolf Kalbermatter

Thanks for this Rolf,

I was hopping it would be easier than this... :o

Link to comment

QUOTE(TiT @ Dec 19 2007, 11:49 AM)

In order to get the correct local time with a timestamp in countries that have a summer time and a winter time (daylight saving stuff) the property has to be disabled in windows.

Are you sure about this (in the recent versions of LabVIEW).

I don't see the issue, but you must be aware that it's all in the eye of the beholder. The default timestamp control is formatted to show DST timing. However if you change the formatter to %^T you will get UTC time.

Ton

Link to comment

QUOTE(tcplomp @ Dec 19 2007, 07:44 AM)

Are you sure about this (in the recent versions of LabVIEW).

I don't see the issue, but you must be aware that it's all in the eye of the beholder. The default timestamp control is formatted to show DST timing. However if you change the formatter to %^T you will get UTC time.

Indeed I concentrated on the technical ability to do what Tit asked for, but in hindsight I would be interested to know, what he wants to fix. LabVIEW 8 has great control over if you want to show UTC or local time and since LabVIEW 7 the date/time conversion for local time considers the timezone that was active at the time the timestamp represents rather than the current time. There are potential issues with the recent dynamic daylight saving time periods, caused by massive adjustments of that period all over the world. In Windows at least, only Vista allows for such dynamic daylight saving time periods. Older Windows versions will always use the current daylight saving period to calculate the local time for any timestamp, even in times where another period was valid.

I would expect that these things can be even a bit less perfect on RT targets, but there you usually shouldn't need to display local time anywhere. Instead just save the numeric timestamp, which was always UTC as long as LabVIEW was multiplatform and then interprete it on the desktop application accordingly.

Rolf Kalbermatter

Link to comment

ZITAT(TiT @ Dec 19 2007, 11:49 AM)

Hello,

In order to get the correct local time with a timestamp in countries that have a summer time and a winter time (daylight saving stuff) the property has to be disabled in windows.

So my question is, how to programmatically enable/disable this windows option ?

Thanks in advance

why you don't you just read out the system time through kernel32.dll (see atached example LV8.0)?

thomas

Link to comment

QUOTE(thomas2609 @ Dec 19 2007, 09:10 AM)

why you don't you just read out the system time through kernel32.dll (see atached example LV8.0)?

That should get you the exact same time that is displayed in a LabVIEW timestamp set not to use UTC!! So not really sure what the benefit of that function would be.

Rolf Kalbermatter

Link to comment
  • 3 weeks later...

ZITAT(LV Punk @ Dec 19 2007, 06:13 PM)

also on http://zone.ni.com/devzone/cda/epd/p/id/18 there are some example VI's, how to get Windows timezone information (from kernel.dll).

Example is quite interesting if someone has to deal with WCHAR.

Link to comment

QUOTE(thomas2609 @ Jan 10 2008, 12:37 PM)

also on http://zone.ni.com/devzone/cda/epd/p/id/18 there are some example VI's, how to get Windows timezone information (from kernel.dll).

Example is quite interesting if someone has to deal with WCHAR.

Hello,

Does this actually works for you ? I have WIN XP Pro and for me the only information that is correctly read is the timezone, all the other information that are read do not correspond to the actual windows date and time ; and the write function does not seem to have any effect :o

Any idea ?

Link to comment

QUOTE(TiT @ Jan 14 2008, 04:18 AM)

Hello,

Does this actually works for you ? I have WIN XP Pro and for me the only information that is correctly read is the timezone, all the other information that are read do not correspond to the actual windows date and time ; and the write function does not seem to have any effect :o

Any idea ?

They do work but they do not return or modify the actual time in DST and non DST format but the current switch over time to start DST and end it.

Rolf Kalbermatter

Link to comment

ZITAT(TiT @ Jan 14 2008, 10:18 AM)

Does this actually works for you ? I have WIN XP Pro and for me the only information that is correctly read is the timezone, all the other information that are read do not correspond to the actual windows date and time ; and the write function does not seem to have any effect :o

i do have the same problem, but Bias is correct!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.