FW: timezone code - re-entrancy issue

Robert Elz kre at munnari.OZ.AU
Tue Jan 13 03:27:57 UTC 2009

    Date:        Mon, 12 Jan 2009 17:45:39 -0500
    From:        "John Dlugosz" <JDlugosz at TradeStation.com>
    Message-ID:  <450196A1AAAE4B42A00A8B27A59278E70925C93A at EXCHANGE.trad.tradestation.com>

  | So what is the way, in this code (or POSIX), to get the name of the
  | timezone?

For what you ask there, there is none, here, or elsewhere.  tzname[]
(despite its name) is not that, it is the current timezone abbreviation
(which in this code is better obtained from tm_tzname if it is really
needed for anything - I'd actually suggest avoiding its use if you
possibly can, use the numeric offset instead).

In POSIX my guess is (I'm no POSIX expert) that strftime("%Z") is
probably the correct way, that at least allows for some degree of
localisation, which localtime() certainly does not.

  | And I assume what is really wanted is the name at the time of
  | interest, so you can label output with the local time and the
  | abbreviation.

If it is just for human consumption, and the human will already have a pretty
good idea what zone might be being referenced, then the zone abbreviation
is probably acceptable - you just cannot rely on its value being useful for
anything more than that (they're wildly ambiguous, and in the timezone
package, for some zones, totally arbitrary and meaningless - in many 
(particularly smaller) countries the time is just the time, and has
no name by which it is distinguished from the time someplace else.)

  | (Forgive me for using Outlook;

Ah, sorry, that one is a sin beyond redemption - eternal damnation is
your only prospect...


More information about the tz mailing list