Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG: Constructing Timestamp from local time + offset + time zone yields wrong offset #7833
Comments
|
this is actually a bit tricky, because you are passing an already localized tz, then what is the |
jreback
added the
Timezones
label
Jul 24, 2014
jreback
added this to the
0.15.0
milestone
Jul 24, 2014
|
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') |
jreback
added the
Bug
label
Jul 24, 2014
|
It looks to be caused by
|
ischwabacher
changed the title from
BUG: Constructing `Timestamp` from local time + offset + time zone yields wrong offset to BUG: Constructing Timestamp from local time + offset + time zone yields wrong offset
Jul 24, 2014
|
@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
# NoneSo 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 |
ischwabacher commentedJul 24, 2014
xref #7825
This bug is inherited from
datetime, which is using local mean time (the first entry forAmerica/Chicagoin tzinfo).