On Wed, 14 Aug 2019 18:10:12 -0400, Phil Smith III wrote:

>I have a C POSIX application that writes timestamps on its output. It's always 
>produced a GMT timestamp (pardon me, UTC), and that's sort of fugly, so I 
>thought maybe I could fix it.
>
>Looking at the code, it's using ctime(). Ok, hey, localtime() should be 
>gooderT! Nope, per IBM doc:
>
>*  The ctime(), localtime(), and mktime() functions now return Coordinated 
>Universal Time (UTC) unless customized locale information is made available, 
>which includes setting the timezone_name variable. 
>
>*  In POSIX you can supply the necessary information by using environment 
>variables.
>
>Gee, thanks (and what does "now" mean in that first sentence? As opposed to 
>tomorrow?? Last week???).
>
>I'm not in a position to set environment variables for this. I know the 
>hardware is set to UTC, but there's a system timezone offset at some level. Is 
>there no simple way to just say "Gimme the same time as the operator's console 
>would show"? Searching sure hasn't found one, hoping someone knows better!
> 
(Actually, the hardware is set, not to UTC, but to TAI - 10 seconds.  See PoOp.)

I believe "now" means "current release".  They seem to be reserving the
right to change.

Is this for your own site, or distribution to customers?

"environment" variables are local to your execution image.  You can set and 
change
them without affecting the outside world.

Investigate tzset().

z/OS is woefully inconsistent intreatment of timezones.  It seems compelled to
regard Classic and UNIX as separate, noninteracting worlds.  Other UNIX-like
systems provide a sytem default timezone, e.g.:
    580 $ ls -l /etc/localtime
    lrwxr-xr-x  1 root  wheel  40 Jul 20 09:58 /etc/localtime -> 
/var/db/timezone/zoneinfo/America/Denver
I tried to report this as a defect in an SR.  WAD.  It must remain broken for
compatibility with AIX.

You might be able to spawn() (BPX1SPN) a shell command to return what
the site's shell sees as TZ.

Java may do it better.  And it uses the zoneinfo data base.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to