From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a37:688c:: with SMTP id d134mr2659305qkc.450.1588423602835; Sat, 02 May 2020 05:46:42 -0700 (PDT) X-Received: by 2002:a9d:b85:: with SMTP id 5mr7255002oth.81.1588423602150; Sat, 02 May 2020 05:46:42 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 2 May 2020 05:46:41 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2001:8b0:ca:2:0:0:0:fd; posting-account=TiHetgoAAACluCgYkPc8-TWs6dBNgSne NNTP-Posting-Host: 2001:8b0:ca:2:0:0:0:fd References: <4f7d162e-356c-4cc4-abc3-f4cfe195b9cd@googlegroups.com> <9dad342a-7981-4d09-a414-7cec651097ac@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Getting the 3 letter time zone abbreviation From: Bob Goddard <1963bib@googlemail.com> Injection-Date: Sat, 02 May 2020 12:46:42 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58551 Date: 2020-05-02T05:46:41-07:00 List-Id: Here goes... On Linux and the various BSD's, the tm structure has been extended to include: long int tm_gmtoff; /* Seconds east of UTC. */ const char *tm_zone; /* Timezone abbreviation. */ When you make a call to localtime_r, these are filled in with the correct into, at least on Linux. The other big iron Unix's do not have this extension, and neither does Windows. Windows also does not have localtime_r, instead it has localtime_s plus its 32 & 64 versions. On the other Unix's & Windows, a call made to tzset (_tzset on Windows), which fills in tzname (_tzname under Windows). This should contain 2 record for non-saving & saving timezone name. and the correct entry can be garnered by way of tm_isdst. To set another timezone, external var TZ should be set. And don't test an example time of 1234 seconds past epoch for the UK expecting GMT. The UK was in fact in daylight saving time and double time (I think) for a few years. In my defence, I was only about 7yo and totally forgot about it. There, clear as mud. This works on Linux, the tm_zone is filled in by the call automatically... with System; with Interfaces; with Interfaces.C; with Interfaces.C.Strings; package Unix is type tm is record tm_sec : Interfaces.C.int; tm_min : Interfaces.C.int; tm_hour : Interfaces.C.int; tm_day : Interfaces.C.int; tm_mon : Interfaces.C.int; tm_year : Interfaces.C.int; tm_wday : Interfaces.C.int; tm_yday : Interfaces.C.int; tm_isdst : Interfaces.C.int; tm_gmtoff : Interfaces.C.long; tm_zone : Interfaces.C.Strings.chars_ptr; end record; pragma Convention (C_Pass_By_Copy, tm); procedure localtime_r (T : System.Address; TM_Struct : System.Address); pragma Import (C, localtime_r, "localtime_r"); end Unix;