Poked around some more, found
https://groups.google.com/forum/#!msg/bit.listserv.ibm-main/mYYcbXg0lGY/hu0cNy5TO30J
which looked promising, but this:
time_t ltime;
static char hhmmss[9];
struct tm *tmptr;
char* timeptr;
time(<ime);
setenv("TZ","CST6CDT",1);
tzset();
tmptr = localtime(<ime);
timeptr = asctime(tmptr);
memcpy(&hhmmss, timeptr+11, 8);
hhmmss[8] = 0;
return(hhmmss);
.produces the same results as before! Note that I hard-coded the CST6CDT after
my first attempt made no difference, on the theory that maybe the TZ variable
wasn't set in the runtime environment.
Now someone can laugh and point out the stupid mistake I made (I hope).
From: Phil Smith III [mailto:[email protected]]
Sent: Wednesday, August 14, 2019 6:10 PM
To: [email protected]
Subject: Local time in C on z/OS
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!
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN