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

Consider introducing a separate RegionTimeZone class #326

Open
dkhalanskyjb opened this issue Dec 1, 2023 · 2 comments
Open

Consider introducing a separate RegionTimeZone class #326

dkhalanskyjb opened this issue Dec 1, 2023 · 2 comments
Labels
breaking change This could break existing code timezone The model and API of timezones
Milestone

Comments

@dkhalanskyjb
Copy link
Contributor

dkhalanskyjb commented Dec 1, 2023

Right now, we have an all-encompassing class TimeZone and its subclass, FixedOffsetTimeZone: TimeZone.

TimeZone can be an interface instead, with two separate implementations: FixedOffsetTimeZone and RegionTimeZone. We could split the time zones by what identifier they have:

  • IANA tzdb identifiers, like Etc/UTC or Europe/Berlin,
  • and generic identifiers like GMT+01:30.

An upside is that a RegionTimeZone would always have a valid IANA timezone database identifier, guaranteed to be recognized everywhere: see #222. A downside is that Etc/UTC is also semantically a fixed-offset time zone, but wouldn't be marked as such. Also, something like Etc/UTC is not even a region, so maybe another name is needed.

@dkhalanskyjb dkhalanskyjb added timezone The model and API of timezones breaking change This could break existing code labels Dec 1, 2023
@kevincianfarini
Copy link

Do the names NamedTimeZone and AnonymousTimeZone fit here? The former would be an entry in tzdb, and the latter would essentially just wrap a UtcOffset.

Thanks for taking a look into this!

@straight-shoota
Copy link

The current model is pretty good and correlates with well defined terms in the time zone handling.
The general concept is called a time zone. A fixed-offset time zone is considered a specialization.

From a programmer's perspective, fixed-offset is simpler and has less features than a dynamic offset, which might suggest the inheritance should be inverted. But from a domain modeling perspective, this doesn't really make sense.
Every time zone has a name and maps an offset to any specific instance of time. That name can be an IANA identifier or not. The offset can be always the same or not.

@dkhalanskyjb dkhalanskyjb added this to the 0.9.0 milestone Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This could break existing code timezone The model and API of timezones
Projects
None yet
Development

No branches or pull requests

3 participants