oz / tz

🌐 A time zone helper
GNU General Public License v3.0
851 stars 33 forks source link

Daylight Saving Time (DST) support #59 #62

Closed jnd-au closed 1 month ago

jnd-au commented 1 month ago

This PR adds DST support and Unit Tests to contribute significantly toward a tz v1.0.0 release. It fixes pre-existing issues up to v0.7.0 (@oz) plus it fixes new unreleased regressions in HEAD (@wyne). Until now, tz has never properly supported DST transitions.

This PR includes the following fixes:

  1. Support missing and duplicated DST hours, same as real-world clocks (fix 092a39a, fix #59)
  2. Support dynamic timezone name abbreviations for daylight-saving transitions e.g. CET versus CEST (fix 0bdd6e2, fix #59)
  3. Support correct DST date markers, including for midnight DST changes (fix 01ff381, fix #59)
  4. Support fractional-hour timezone offsets and stable keyboard navigation (fix cb3ba9f, fix #60)
  5. Do not zero out the minutes during keyboard navigation, unless requested by the user (fix cb3ba9f, #60)
  6. Show -list search syntax (fix d6c5408)
  7. Unblock unit tests by making the time and zone properly settable, not dependent on the current time or user environment (fix 0bdd6e2, fix #57)
  8. Extensive unit-test coverage >80% with 95-100% coverage for most files, except main.go (fix #56)

Due to the extensive refactoring of core tz logic, this PR is quite ‘big’ so I’ve sub-divided it into small commits that are more easily reviewable. I’ve added baseline unit test data from v0.7.0, then incrementally updated it to show the impact and necessity of each change.

This PR includes the following new features to make DST clearer:

  1. Show DST start & end markers
  2. Show numerical UTC offset for timezones (z key)
    • This helps resolve user confusion about timezone names, as the “ST” abbreviation is ambiguous and can either mean “Standard Time” (no daylight saving) or “Summer Time” (with daylight saving).
  3. Show ISO datetime format (f key)
  4. Highlight a particular timezone in the output (j/k keys)
  5. Keyboard navigation to add/subtract one minute at a time (-/+ keys)

This PR depends on first merging PRs #54 and #61 (commits on 9 and 13 October), as they contain pre-requisite fixes as a basis for the functionality and unit-test data/expectations in this PR. Hence I’ve raised this as a Draft for the time being, although it’s ready for review (commits starting 14 October).

oz commented 1 month ago

Thank you! 🙌🏻