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

Add ability to specify timezone database location via environment variable #807

Conversation

samuel-emrys
Copy link

@samuel-emrys samuel-emrys commented Jan 13, 2024

This adds the ability for a user to populate the TZDATA environment variable to specify the location in which to look for the timezone database, which allows for a runtime query of this location. Without this, date currently only supports compile time determination of the database location.

This facilitates the ability to:

  • Use a timezone database provided by a package manager
  • Keep the timezone database up to date without re-compilation
  • Be flexible about where the timezone database is stored

This is a simplification of #611, removing windows support for a zic-compiled binary database, so that it only adds environmental variable features.

Closes #788

…iable

This adds the ability for a user to populate the TZDATA environment
variable to specify the location in which to look for the timezone
database, which allows for a runtime query of this location. Without
this, date currently only supports compile time determination of the
database location.

This facilitates the ability to:
* Use a timezone database provided by a package manager
* Keep the timezone database up to date without re-compilation
* Be flexible about where the timezone database is stored

Closes HowardHinnant#788
samuel-emrys added a commit to samuel-emrys/conan-center-index that referenced this pull request Jan 13, 2024
* Add tz recipe as a dependency to provide a way of easily
  consuming/maintaining and upgrading the timezone database
* Apply patch from HowardHinnant/date#807 to add the ability to specify
  the tz database by environment variable
* Deprecate `use_system_tz_db` in favour of `with_tzdb` option to handle
  all mutually exclusive options
* Add `with_db_format` option to provide flexibility in how the tz
  package is consumed.

This implementation superesedes conan-io#16285 and conan-io#21719. In the case of conan-io#21719,
it turned out that HowardHinnant/date#611 was not mature enough to
provide the ability for the date library to read zic-compiled binary
variants of the tzdb on Windows. To take an iterative approach, this PR
aims to extract the elements that worked from conan-io#21719, which was the use
of an environment variable to inject the conan packaged tz database.

Use of a binary database has been marked as an invalid configuration on
Windows. This functionality can be added at a later date.

This pull request is blocked on conan-io#21671, which packages the source
database in the tz recipe and makes this the default configuration since
this is the only database that can be parsed consistently on all major
platforms.

Closes conan-io#16204
@szaszm
Copy link

szaszm commented Aug 28, 2024

Thank you, this would make my life easier as a Nix and NixOS user, where the timezone database is at /etc/zoneinfo. More details: https://stackoverflow.com/questions/3896587/are-linuxs-timezone-files-always-in-usr-share-zoneinfo

@basilgello
Copy link
Contributor

Leaving this up to @HowardHinnant because NixOS uses pretty new compilers that support C++20 calendars and time zones natively

@samuel-emrys
Copy link
Author

This ticket had nothing to do with NixOS except someone finding utility in it using NixOS - not sure why that means it's not relevant anymore.

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

Successfully merging this pull request may close these issues.

Run time specification of tzdb location with environment variable
4 participants