Skip to content
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

Suggestion: Create public API for timezone from Posix strings and TZif files #1628

Open
AVee opened this issue Nov 11, 2024 · 1 comment
Open

Comments

@AVee
Copy link

AVee commented Nov 11, 2024

The handling of Local timezones includes code to parse both timezone information files and Posix timezone strings. This code is currently driven from either a TZ environment variable or a /etc/localtime symlink. But it seems there is no public API available to create these timezone manually from either a file or a string.

It would be useful to have a public API where you could do something like TimeZone::from_file() and TimeZone::from_posix_string(). This is probably mostly useful in (embedded) no-std scenarios where there is no concept of a 'configured' timezone on the OS level and timezone information comes from application specific configuration. There might be other uses too. A minor side benefit would be that it would allow for easy testing against for instance all timezone files as generated from the Iana database.

For handling files tzfile does exist, but it has some limitations because it doesn't handle Posix strings and therefore cannot do far future transitions. But more importantly, the required code is already present in Chrono anyway so it seems somewhat useless to duplicate it.

@djc
Copy link
Member

djc commented Nov 12, 2024

I'm open to reviewing a PR for such an API.

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

No branches or pull requests

2 participants