1758650 Members
2202 Online
108874 Solutions
New Discussion юеВ

mktime in a C program

 
SOLVED
Go to solution
labadie_1
Honored Contributor

mktime in a C program

Alpha Vms 7.3-1 unpatched (no ACRTL or TDF patch or any, this is a test machine)

A program using mktime gives a one hour drift from the system time (minus one hour).
When I ask for a time after the next time change (last Sunday of October), it is plus one hour.
Anyway, always incorrect.

I seem to recall that tzset had a relationship with that. At
http://h71000.www7.hp.com/commercial/c/docs/5763p053.html

but if somebody has an example of using tzset, it would help.
5 REPLIES 5
John Gillings
Honored Contributor

Re: mktime in a C program

Gerard,

There have been several fixes to timezones, so it would be best to get your system up to rev first.

Check what your timezones set to, then check the definitions. If the definitions are wrong, have a look at the timezone update procedures at:

http://ftp.hp.com.au

Although these are for Australian & New Zealand timezones, I'm sure you can use them as templates to fix yours.

(and if you're running DECnet+, don't forget to fix those zone definitions too!)
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: mktime in a C program

>>> A program using mktime gives a one hour drift from the system time (minus one hour).


Or.. it is returning UTC.
In Greenwich it one hour earlier then local for you no?

fwiw,
Hein.
labadie_1
Honored Contributor

Re: mktime in a C program

I think the setup is correct (for France) on the node

$ sh log *zone*

(LNM$PROCESS_TABLE)

(LNM$JOB_818E2080)

(LNM$GROUP_000001)

(LNM$SYSTEM_TABLE)

"SYS$TIMEZONE_DAYLIGHT_SAVING" = "1"
"SYS$TIMEZONE_DIFFERENTIAL" = "7200"
"SYS$TIMEZONE_NAME" = "MET DST"
"SYS$TIMEZONE_RULE" = "MET-1MET DST-2,M3.4.0/02,M10.5.0/03"

(LNM$SYSCLUSTER_TABLE)

(DECW$LOGICAL_NAMES)


I have found in comp.os.vms a post by David Jones which says

You've got it backwards, decc$fix_time is NOT adding the differential while
time() is subtracting it (in order to give the illusion that the system clock
is UTC). The ctime() expects its argument to be UTC and then adjusts the
displayed time returned by whatever the current timezone setting (TZSET) is.
The documentation should be clearer that decc$fix_time() does not do any
timezone adjustments, but I think it's use is discouraged anyway.

The crux of the problem is that VMS's system clock uses local time rather than
UTC. The timestamps in the file system are local time also, which causes
similar grief with the times returned in stat structures.


David L. Jones
Vouters
Advisor
Solution

Re: mktime in a C program

Hi Gerard,

Can you test this program on your computer?
Also use the ctime function to get the local time.
Regards,
Philippe
labadie_1
Honored Contributor

Re: mktime in a C program

Thanks a lot Philippe, this is exactly what I was looking for.