djgpp: Set TZ=UTC to convert UTC timestamp to time_t
authorJ.W. Jagersma <jwjagersma@gmail.com>
Mon, 26 Sep 2022 18:35:46 +0000 (20:35 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 29 Sep 2022 10:00:30 +0000 (12:00 +0200)
commitcffb65f2ff85f19418ed121275901674824e52ca
treef44f1e557bbe0a008d2eae61489835a9e3631a38
parent8ae74c5bc091e7388c082f090c1fde992c31320f
djgpp: Set TZ=UTC to convert UTC timestamp to time_t

Since djgpp has neither a timezone variable or timegm(), this horrible
method must be used.  It is the only one I could find that produces
accurate results, and is recommended as portable alternative to
timegm() by the GNU libc manual.  Reference:

https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html#index-timegm

Now, a much nicer alternative solution could be:

    timestamp_local = mktime(timestamp_tm);
    timestamp_utc = timestamp_local + timestamp_tm->tm_gmtoff
                                    - (timestamp_tm->tm_isdst ? 3600 : 0);

This works due to the fact that mktime() populates the tm_gmtoff and
tm_isdst fields in the source timestamp.  It is accurate everywhere in
the world, *except* on Lord Howe Island, Australia, where a 30 minute
DST offset is used.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19274)
crypto/asn1/a_time.c