-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Constructing Timestamp from local time + offset + time zone yields wrong offset #7833
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
this is actually a bit tricky, because you are passing an already localized tz, then what is the |
cc @rockg |
But I really think the only unambiguous way to construct an aware datetime from local time is if both the time zone and the offset are also present. Offset lets you convert to UTC, where you look up the correct offset for the time zone at that UTC time and compare it to the offset again. If they match, great. If they don't match, you can either correct the offset or give a NonExistentTime error, and which of these you do should probably be determined by a EDIT: Another benefit of fixing this: In [1]: from pandas import Timestamp
In [2]: Timestamp('2013-11-3', tz='America/Chicago')
Out[2]: Timestamp('2013-11-03 00:00:00-0500', tz='America/Chicago')
In [3]: eval(repr(_))
Out[3]: Timestamp('2013-11-02 23:09:00-0551', tz='America/Chicago') |
It looks to be caused by
|
Timestamp
from local time + offset + time zone yields wrong offset
@sinhrks yep yes I think if the current |
It might be best if the conversion only happens when Then there's this problem: In [20]: dateutil.parser.parse('2013-11-3 00:00:00 CDT').tzinfo
Out[20]: tzlocal() # local TZ is America/Chicago
In [21]: dateutil.parser.parse('2013-11-3 00:00:00 EDT').tzinfo
# None So I'm not sure we even can do the right thing in all cases without messing with Also, EDIT:
I agree that this is how it's defined, but I think it's better to think about what information we need about a time in order to do what the user wants. Ultimately, I think the user (and here I'm generalizing from a sample size of 'me') wants to be able to relate times in a particular place. Fixed offset time zones are a tool for doing this (and I use them because I collect data using time-zone-naive devices for which the offset is only guaranteed to be correct at the start of the collection window), but in general I suspect that most of the time that a user gets a |
@ischwabacher, @sinhrks is talking about a much lower-level object, called a
|
EDIT: But I did fail to notice that there's a |
xref #7825
This bug is inherited from
datetime
, which is using local mean time (the first entry forAmerica/Chicago
in tzinfo).The text was updated successfully, but these errors were encountered: