-
Notifications
You must be signed in to change notification settings - Fork 537
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
Add a method to the Offset
trait to return DST info
#1562
Comments
I would be inclined to make this method return just |
Oops, replied on the wrong issue. Copying here. (Not a reply, just some things I'm thinking about.) Summer and winter timeThe concepts of 'daylight saving time', 'standard time', 'summer time' and 'winter time' are related but not the same. What is called 'summer time' often matches 'daylight saving time', with 'winter time' being the standard time. But countries may just as well define their 'summer time' the be the 'standard time', in which case 'winter time' will be encoded as 'saving'. Then there are many time zones that don't make a distinction between either, or only made the distinction for a couple of years. And of course There can be reasons other than the seasons to switch to/from the standard offset within a time zone. In the US during World War II there has been 'war time', with a three year long DST. Or summer time (to make optimal use of daylight) may temporary revert to standard time during ramadan (where you eat beyond daylight). Contries may also move away from DST, and declare their daylight saving time to last the whole year. At this point it becomes the 'standard time' and is encoded as such in the database. From only the DST info with However in a Because users may expect 'daylight saving time' to be the same thing as 'summer time', we should consider this difference instead of only naively exposing the basic data. The time zone database contains a treasure trove of documentation around DST weirdness. Before suggesting a definitive API I'd like to read all the documentation the database has around it. That seems doable. Some parts from the database: Greenland
Ireland
Czech Republic and Slovakia (Europe/Prague)From 1947 to 1979 Czechoslovakia had a standard time and a winter time where the winter time differed by -1:00 hour from standard time. MaroccoMarocco has a super complex story when it comes to DST. It has a summer time, to make more use of the available daylight, but switches back to standard time during the ramadan (to eat after dark). This caused four DST changes per year in 2012 to 2016. And in 2018 it switched its definition of standard time, causing the 'saving' time to have a -1:00 hour offset to the standard time. Namibia
MoscowRussia observed DST until it switched to permanent 'summer time' all year long in 2011. In October 2014 it switched to permanent standard time.The time zone database does not encode a permanent 'summer time', but considers this a change to the standard time. |
👍 After searching for it again I can only find two... #235 and chronotope/chrono-tz#130. #10 (comment) and #120 are not clear.
I like returning an The story for chrono seems similar to Also I think it is good to have one method on a trait that returns all info that is available. Other methods can be added to the |
😄. Sometimes I am thinking out loud in these issues, sorry. Please read this one more as exploring an idea than proposing a concrete plan. If we add a method such as Essentially we would bring the functionality of the |
Sure, that seems reasonable. |
We have had multiple requests to provide a way to get DST information for a
DateTime
.Not all offset types carry this information.
Utc
andFixedOffset
rightfully only encode an offset from UTC. Also some APIs may not give the information. So the method should not just returntrue
/false
but three variants:During DST the time is usually +1 hour shifted relative to the standard offset for that time zone. But there exist other values, such as +0:30, +1:30, +2:00, and -1:00. I propose to return the extra offset in the
Saving
variant as aFixedOffset
.What should be the fallback if you want to create an offset for an API that only provides a boolean for the DST status?
Honestly TZif files,
chrono-tz
and the Widows API have the full information. As I understand from discussions around the IANA time zone database an API that only returns a boolean is usually broken in various ways already (like handling a negative DST offset). We can leave the question up to the implementation that wraps it. I don't think it should effect our API.Adding this method is backward-compatible if we give it a default implementation that returns
DaylightSaving::Unknown
.The text was updated successfully, but these errors were encountered: