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

Feature runtime tzdb #6

Closed
wants to merge 5 commits into from
Closed

Feature runtime tzdb #6

wants to merge 5 commits into from

Conversation

DavisVaughan
Copy link
Member

This PR allows for setting the time zone data base directory path at runtime. It does not yet work on Windows, because there might be some code that needs to be changed in the binary tzdb parser so that it works on Windows, but is a pre-requisite step towards that.

The first 3 commits are related to <date> changes, the rest of them are civil related changes to use the custom binary location to see if things work. I fully expect the github actions builds to break, that is unrelated to these changes.

There is a new option USE_BINARY_TZDB. USE_OS_TZDB can be thought of as a subset of this. If USE_BINARY_TZDB is turned on, but USE_OS_TZDB is not, then the client is required to call set_tz_dir() before initializing the tzdb, otherwise a runtime error is thrown.

If USE_BINARY_TZDB is not defined, then it is set to USE_OS_TZDB to be compatible with all previous versions of date.

Previously, discover_tz_dir() and get_tz_dir() were always defined if on a non-Windows platform, even if USE_OS_TZDB was not defined. I considered this a bug. discover_tz_dir() is now only defined when USE_OS_TZDB is on, and get_tz_dir() is defined if either USE_OS_TZDB or USE_BINARY_TZDB is defined. It is required for this to be implemented this way to eventually add support for USE_BINARY_TZDB on Windows (i.e. we can't just turn off support for these when on Windows).

I have changed the non-Windows implementation of current_zone() to only call get_tz_dir() when USE_OS_TZDB is on. This is a direct result of the previously mentioned change. It seemed like the call to get_tz_dir() is only used in embedded systems and is related to a symlink to an OS tzdb path, so it really feels like USE_OS_TZDB should have to be active for this to work. It would not be sufficient for USE_BINARY_TZDB to be on, because this could be a custom location that the symlink probably won't point to.

This re-includes USE_OS_TZDB as a subset of USE_BINARY_TZDB. If USE_BINARY_TZDB is set, but USE_OS_TZDB is not, then the client must call set_tz_dir() before initializing the tzdb to set the path to the binary tzdb.
@DavisVaughan
Copy link
Member Author

Closed in favor of #49

@DavisVaughan DavisVaughan deleted the feature/runtime-tzdb branch January 29, 2021 21:45
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.

1 participant