-
Notifications
You must be signed in to change notification settings - Fork 115
Support obtaining the system timezone on old Debian-based distributions #503
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…er and print the result of them
… <UTC>, actual <Z>
fzhinkin
reviewed
Mar 20, 2025
dkhalanskyjb
requested changes
Mar 31, 2025
dkhalanskyjb
approved these changes
Mar 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! I believe it's good to go. I've checked this on a Jessie VM, and the problem is both 1) real and 2) solved by this PR.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue Background
On older Debian-based distributions (between Etch 4.0 and Jessie 8.0), the system timezone configuration is stored differently than on most modern Linux distributions. Instead of using a symbolic link for
/etc/localtime
, these Debian versions used a regular file copied from the zoneinfo directory.The current implementation in
kotlinx-datetime
only supports finding the timezone via the symlink method, which fails on these systems. Even though these Debian versions are past their support date, they remain in use in various environments, making this fix valuable for broader compatibility.Solution
I've modified the
currentSystemDefaultZone()
method to implement a fallback mechanism when the symlink approach fails:/etc/timezone
file/etc/localtime
with the corresponding zoneinfo fileThis implementation gracefully handles all possible configurations while maintaining robust validation to prevent silent failures and incorrect timezone reporting.
Testing Approach
To thoroughly test this fix, I created a comprehensive test suite using testcontainers that verifies correct behavior across different system configurations:
Modern Systems (Ubuntu Noble)
Legacy Systems (Debian Jessie)
/etc/timezone
when configured correctly/etc/localtime
is missingThe testcontainers approach provides several advantages:
Additionally, all standard timezone tests from the common package also pass in the correctly configured containers, confirming that core functionality remains intact.
Summary
This fix significantly improves the robustness of the
kotlinx-datetime
library by extending timezone detection support to older Debian-based systems while maintaining strict validation. The comprehensive test suite ensures reliability across diverse system configurations.