New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assume UTC if "tzdata" are not available #153
Comments
What do you mean by 'assume UTC' / 'fallback to UTC'? TZInfo has no concept of a current time zone. The Fedora advice seems targeted at applications that need to know the system time zone. For that, assuming UTC would make sense. I see four possible options:
I think option 1 would cause confusion. Currently, an exception is thrown when there's no available data source. The behaviour would change to Option 2 perhaps doesn't add much. If you're going to have to explicitly 'opt-in' to UTC-only, then you could also make a zoneinfo directory available with just a UTC zone (or install a complete set of time zone data). Regarding option 3, TZInfo is intended to expose the data from the (IANA Time Zone Database) data source without making any changes. Forcing 'UTC' to be available doesn't fit with that philosophy. Some thought would also be needed on what methods like Option 4 sidesteps the issues with option 3. However, it would require downstream users, such as ActiveSupport, to handle UTC as a special case. They could presumably do that anyway without using TZInfo. I'm not really convinced a change is needed. Fundamentally, TZInfo is a library for handling time zone conversions. It doesn't seem unreasonable that a source of time zone data should be required to use it. |
From the options you proposed, the option 1 or 3 are something along the lines I imagine. I believe that in the context of rails/rails#49375, it would solve 99% of use cases, because the default value is 'UTC' |
For reference, the IANA Time Zone Database time zone ActiveSupport currently looks for when asked for 'UTC' is actually 'Etc/UTC' (via 'Etc/UTC' is the canonical UTC time zone in the current version 2023c of the IANA Time Zone Database. It also contains the following aliases: 'Etc/UCT', 'Etc/Universal', 'Etc/Zulu', 'UCT', 'Universal', 'UTC' and 'Zulu'.
As I outlined, I'm not keen on of either of those options. Option 1 would lead to confusion (and break the missing time zone data check on startup of Rails). Option 3 deviates from the design philosophy - the data is supposed to all be provided externally. It would just about be possible to modify If option 4 was implemented, then the |
@rafaelfranca would some of the proposals be acceptable for Rails? If not, then I think we can close this ticket |
Recently, tzdata were removed from default Fedora installation (and this will eventually impact also RHEL). Now running ActiveSupport test suite (but also other test suites) we are facing erros such as:
It seems this cannot be workaround on ActiveSupport side, but would there be and option to fallback to UTC, when no tzdata are found? It seems that this is the consensus, reiterated in this Fedora thread:
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/C37PSJNLJDOUZEBBWGTUSW6UZVT6BXKI/
The text was updated successfully, but these errors were encountered: