Skip to content

Fix OpenHarmony's tzdata parsing #1679

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix OpenHarmony's tzdata parsing #1679

wants to merge 2 commits into from

Conversation

ldm0
Copy link

@ldm0 ldm0 commented Mar 20, 2025

OpenHarmony's tzdata parsing supported was introduced in #1613.

OpenHarmony's tzdata shares the same characters with the ones on Android, except that each timezone index is 4 byte's smaller(the legacy rawUtcOffset was removed).

OpenHarmony's tzdata
Android's tzdata

As their parsing logic are pretty similar, I unified their logic into src/offset/local/tzdata.rs(I actually created a crate for that, but the logic is simple enough to put into chrono). This also allows us to remove the android_tzdata dependency.

BTW, OpenHarmony's tzdata parsing logic was also added in fallback_timezone, that's because OpenHarmony doesn't have /etc/localtime, people need to use it's time service api to get the timezone name. I created a PR for iana-time-zone to support OpenHarmony's timezone name fetching: strawlab/iana-time-zone#150. After getting the timezone name from iana_time_zone::get_timezone, chrono need to find it's timezone information in the tzdata.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.67%. Comparing base (39fb201) to head (15a9940).
Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1679      +/-   ##
==========================================
- Coverage   91.08%   90.67%   -0.41%     
==========================================
  Files          37       39       +2     
  Lines       17469    17070     -399     
==========================================
- Hits        15912    15479     -433     
- Misses       1557     1591      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djc
Copy link
Member

djc commented Mar 20, 2025

This should come with CI coverage for Android and OpenHarmony. The new parser should be cleaned up, have a look at the rustls style guide (which I wrote) and try to simplify (drop the OS constructor, make the constant names more concise, avoid nested types/functions).

@ldm0
Copy link
Author

ldm0 commented Mar 21, 2025

@djc Hi, all new lines are covered now, and parser was cleaned up. Please take a look.

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.

2 participants