AIX: timezone globális változó

Arra való ugye, hogy megtudjuk, milyen messze van (másodpercben) a mi időzónánk a GMT-től (DST nem számít); értelemszerűen, ha negatív, akkor pozitív, vagyis

TZ=GMT-02:00     => timezone=-7200  => date=20200415.110500+0200
TZ=CET-1CEST-2   => timezone=-3600  => date=20200415.110500+0200
TZ=Europe/Moscow => timezone=-10800 => date=20200415.120825+0300

Szóval vesszük a 'timezone' ellentettjét, azután ha a 'localtime' azt mondja, hogy 'tm_isdst', akkor hozzáadunk 3600-at; ebből könnyen előállíthatjuk azt a stringet, amit a strftime(%z) egyébként is megmondana.

Mármint AIX-on nem, ott a '%z' ugyanazt csinálja, mint a '%Z' (CET/CEST/MSK, ilyesmik).

No mindegy, a gond nem is ez, hanem a manualnak ez az apró bejegyzése:

Attention: Do not use the tzset subroutine when linking with both libc.a and libbsd.a.
The tzset subroutine sets the global external variable called timezone,
which conflicts with the timezone subroutine in libbsd.a.
This name collision may cause unpredictable results.

Ez magában foglalja azt is, hogy a `timezone` változóra nem építhetek, hacsak nem látok a jövőbe, és nem garantálom, hogy ki, mikor, hogyan, hová fogja belinkelni azt a programrészt, amit most tákolok. Szóval egy jó kis platformfüggő #ifdef elágazás lesz ebből; érdekességképpen a diagnosztika program kimenete egy AIX-os gépen:

=== strftime %z %Z ===
utc:   20200415.094201.CET.CET
local: 20200415.114201.CEST.CEST

=== global variables ===
timezone=-3600 daylight=1 tzname=(CET,CEST)
AIX: 'timezone' cannot be used if linked with '-lbsd'.
      Basically, it means 'timezone' cannot be safely used.

=== fields of 'struct tm' ===
tm_isdst=1
AIX: 'tm_gmtoff' and 'tm_zone' don't exist in AIX

=== fields of 'struct timeb' ===
timezone=-60 dstflag=1
POSIX: 'ftime' and 'struct timeb' shouldn't be used, and/or these fields might be unset
Linux: (if filled) these fields contain some system-global setting (TZ-independent)
AIX:   these fields contain TZ-dependent values

=== fields of 'struct tz' ===
tz_minuteswest=-60 tz_dsttime=1
POSIX: 'gettimeofday' shouldn't be used, especially its 'timezone' parameter
Linux: (if filled) these fields contain some system-global setting (TZ-independent)
AIX:   these fields contain TZ-dependent values