LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI Date/Time and Microsoft problems

There seems to be still some confusion with the way CVI handles time & date
compared with MS and Borland products. The archive seems to be consistantly
littered with questions that are unanswered - (to me at least). The Knowledge
Base at NI also speaks of this problem with reference to "TZ" variable -
but this has not fixed the problem. It is further complicated with the correction
for Daylight savings time.

I need to be able to convert the local time to a number that is meaningfull
for both Excel and Borland builder. The time() and now() calls from Borland
work correctly and Excel interprets this number also correctly.

The CVI -Ansi C routines gmtime() and localtime() return the same time even
though the machines tha
t they are running on are set to Australian Daylight
Saving time (GMT+10). These routines don't correct for daylight saving hence
the hour is out by 1. The CVI routine GetSystemTime returns the correct time
but how can I tell if daylight saving time is being accounted for or even
which timezone I'm in? I have tried on two separate machines - one NT4 and
one win95.

the routines I'm using:

thetime = time (NULL); //get the system time

InternationalTime (temp, 20); - returns a string with the hour out by 1

gmt = gmtime(&thetime);
LocalTime = localtime (&thetime); both of the structures have identical elements
with the hours out by one

GetSystemTime (&hours, &mins, &secs); returns the correct hours

strftime (s,100, "%Z", LocalTime); the string returned says the machine
is set to "Aus Eastern Standard Time", Windows is set to Daylight saying
time!

Any ideas that bring some clarity would be greatly appreciated.


Grant Parratt
Research Engineer
Grant.Parratt@amcor.com.au

Amcor Research and Technology
17 Rex Avenue ph: (03) 9490 6100
Alphington fax: (03) 9499 4295
Victoria 3078
Australia
0 Kudos
Message 1 of 2
(3,406 Views)
NI overloaded the Win32 "GetSystemTime" function with their own function - who knows why - seems really stupid to me. I went into one of the CVI header files (that they tell you not to alter) and commented out the NI call so as to expose the "real" Win32 call. Note that the parameters are different in the WIn32 call. Maybe the Win32 call does the job for you. Good luck.
0 Kudos
Message 2 of 2
(3,406 Views)