Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Timezones are wrong #454

Open
ale5000-git opened this issue Sep 19, 2024 · 2 comments
Open

Timezones are wrong #454

ale5000-git opened this issue Sep 19, 2024 · 2 comments

Comments

@ale5000-git
Copy link

ale5000-git commented Sep 19, 2024

Bash online:

$ TZ='UTC' date
Thu Sep 19 03:18:14 AM UTC 2024
$ TZ='Europe/Rome' date
Thu Sep 19 05:18:14 AM CEST 2024
$ TZ='CET' date
Thu Sep 19 05:18:14 AM CEST 2024

BusyBox for Windows:

$ TZ='UTC' date
Thu Sep 19 03:18:14 UTC 2024
$ TZ='Europe/Rome' date
Thu Sep 19 04:18:14 ope 2024
$ TZ='CET' date
Thu Sep 19 03:18:14 CET 2024

There are 2 errors: the hour and the timezone string.
Is it possible to fix them?

@rmyorston
Copy link
Owner

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
~ $

@ale5000-git
Copy link
Author

ale5000-git commented Sep 19, 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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants