We have an embedded Linux system where the user can set a timezone from the system's tzfile list (so names of countries/places, GMT+-n, UTC) or the timezone / $TZ can be directly set in POSIX format (EG CET-01:00:00CEST-02:00:00,M3.5.0/02:00:00,M10.5.0/03:00:00
or EST5EDT
) by a remote server (which does not know timezone names).
Whichever entity set the timezone last (be it human or remote server) we need to report the local timezone setting back to the remote server in POSIX format, preferably with minimal lying / fudging.
Before I roll up my sleeves, don my pointy hat, and start down the road of parsing the tzfile format by hand I thought it worth asking if there is a pre-existing function / library or example of doing this?
I've trawled through the standard libraries and can't see anything that does this specifically.
The tzfile ends with the timezone POSIX format. I don't know if there's a standard library function for it, but all you have to look for is a newline followed by a string and another newline at the end of the file. The string in between is the timezone in POSIX format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With