Open ale5000-git opened 2 months ago
Yeah, Microsoft's timezone handling is a bit rubbish. It's almost as if they hadn't read POSIX properly ;-)
What sort of works is specifying the time zone in full, with offset and DST name:
~ $ date -u
Thu Sep 19 07:43:02 UTC 2024
~ $ TZ=CET-1CEST date
Thu Sep 19 09:43:04 CES 2024
~ $
@rmyorston Is it possible to implement a custom code for some cases?
My idea is: if the TZ match this regexp [A-Za-z]{3,}[+-][0-9]*
then use custom code and skip the windows API.
Looking at bash online
the letters only have a minimum limit of 3 chars but they have no maximum limit so long strings are allowed.
Even a string of over 4000 chars can be displayed correctly.
If the number is higher of 24 it is changed to 24.
If the number is missing it is changed to 0.
-1 sum 1.
+1 subtract 1.
Examples:
$ TZ='AfgdfhTHTHtHhh+1' date
Thu Sep 19 04:03:37 PM AfgdfhTHTHtHhh 2024
$ TZ='ABC-' date
Thu Sep 19 05:03:37 PM ABC 2024
$ TZ='CET-1' date
Thu Sep 19 06:03:37 PM CET 2024
$ TZ='CEST-2' date
Thu Sep 19 07:03:37 PM CEST 2024
Bash online:
BusyBox for Windows:
There are 2 errors: the hour and the timezone string. Is it possible to fix them?