Make embedded timestamps timezone independent #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up for #61, the value of
TZ
still has an impact on the binary (removing theenv::set_var
call in one of the tests makes the test fail as well):With this patch
SOURCE_DATE_EPOCH
makes the embedded timestamp use UTC without build-time localization of the timezone. It also removes build-time localization when embedding the most-recent-git-commit timestamp (this didn't show up in our tests because we've tested with a sourcecode from a tarball).The code could be simplified by always using UTC, then localize the timezone at runtime if needed.
I've dropped one of the tests because calling
Local::now();
afternow_data_time();
is always going to give you a greater value, unless SOURCE_DATE_EPOCH is explicitly set to a value in the future.Thanks!