I think you may be right, Gil. I think it's mktime() that has been my
problem. *It* always creates a time_t on the assumption that the broken-down
time is local time.

A time_t does not really have a time zone: it's an absolute number of
seconds, not a cultural time expression.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@bama.ua.edu] On Behalf
Of Charles Mills
Sent: Tuesday, February 28, 2012 10:49 AM
To: IBM-MAIN@bama.ua.edu
Subject: Re: How convert "historic" STCK to local time?

> Call localtime()

Are you *sure*? In my experiments on both Windows and z/OS it appeared to me
that localtime() did format conversion ("seconds since 1970" to month, day,
year, etc.) but did not convert the time zone. The documentation is less
than precise on the two meanings of "convert" (seconds to "date" versus
local to GMT or UTC).

gmtime(): "Converts the calendar time pointed to by timer into a broken-down
time, expressed as Coordinated Universal Time (UTC). The value pointed to by
timer is usually obtained by a call to the time() function."

localtime(): "The localtime() funtion [sic] converts the calendar time
pointed to by timeval to a broken-down time expressed in local time.
Calendar time is usually obtained by a call to the time() function."

They both take the same input (a time_t from time()) but gmtime() "knows"
it's local time and localtime() "knows" it's UTC?

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@bama.ua.edu] On Behalf
Of Paul Gilmartin
Sent: Tuesday, February 28, 2012 10:18 AM
To: IBM-MAIN@bama.ua.edu
Subject: Re: How convert "historic" STCK to local time?

On Tue, 28 Feb 2012 09:57:44 -0800, Charles Mills wrote:

>Is there any straightforward way to convert an STCK value from some 
>point in the fairly recent (months, not decades) past to local time for 
>the LPAR's locale? By "straightforward" I mean without having to 
>maintain my own table of time changes for the historic period?
> 
Subtract TOD value for Jan. 1, 1970.

Divide by 4,096,000,000.

Set time zone with tzset().

Call localtime() then strftime().

This is good back to about 2006 in the U.S.A.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email
to lists...@bama.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN

Reply via email to