-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
tz_localize should support is_dst input array #7943
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
Comments
we already support |
|
ok, makes sense. would making |
I would like an is_dst keyword and this also mirrors pytz's localize which takes is_dst as a parameter. I agree that it is an error if is_dst is not None and infer_dst=True (they are mutually exclusive). I'll take a stab add adding it to localize. Should be straightforward if I recall. |
ok, sounds good |
I suspect that That said, since the problem of converting local time and time zone to UTC (essentially inverting the time zone, if we view it as a map from UTC to local time) is simply one of selecting the correct UTC time from a list of zero, one or two times, and since in the case of an ambiguous time at a DST boundary the DST time must always come first, I propose that if we use I also propose that we not put any effort into supporting the case where there are three or more UTC times corresponding to a given local time, because this case requires pathological government action and I don't know of any instance where it has happened. |
Your second paragraph is not exactly correct and why this is needed. If you only had two ambiguous times, then the Item,Time,IS_DST |
What I'm proposing is that (if you are in
Which is just as good. |
Yes, I know that's your first point...I was more addressing your subsequent points. I agree that it's just as good and contains the same information. My data is structured with bools and hence I want to make that work (it was only a couple lines of code to make this work). I don't know offhand how to make the offsets in the underlying tz_localize code. I don't see any harm in making both work if possible. |
To @ischwabacher's point, I'm not against adding I always store timestamp in UTC in database to avoid ambiguity, unless the database has explicit support for |
While storing data in UTC is unambiguous, it makes it very difficult when people are working with data in the database. With my work, having the data stored in the actual time zone has saved many errors with users not having to manually do the dst offset in their heads...it's so much easier and not worth the hassle for only 2 out of 8760 hours. |
...sorry, I can't count. My second paragraph was talking about resolving one individual time, not inferring DST from the whole vector. So But not all time zone discontinuities are DST boundaries (and not all DST boundaries are time zone discontinuities)! Here's what
Clearly, we need a way to handle this case; also clearly, the mechanism should be the same as the handling of the DST case because the same basic thing is going on: the time zone offset is jumping down as we cross a boundary. My most preferred solution to this problem is to make it easy and natural to use local time + offset to specify time, but this will be a pain in the butt sometimes (and you don't want to make your users remember that it's 24 minutes, especially since EDIT: Just noticed that the proposed commit does essentially what I suggested. I still prefer something like |
It has frustrated me about If anybody is actually dealing with 1915 hourly Warsaw times I will be very interested. I think we have a decent solution to cover 99.99% of the cases people use this for. I do like the |
Offsets sometimes change for geopolitical reasons. |
When storing datetimes with timezone information in mysql I split out the is_dst flag into a separate column. Then when reconstructing the Timestamps I am either forced to iterate through each row and call pytz.timezone.localize on every Timestamp which is very slow or do some magic with localizing what I can and then manually dealing with the fall transition time (note that infer_dst won't work because there could be many rows that have transitions in them). I would much rather create the DatetimeIndex from the column of dates and then call tz_localize with the is_dst column. This would then appropriately set the offset.
Thoughts?
The text was updated successfully, but these errors were encountered: