Skip to content

Timestamp('now', tz=xxx) result wrong #9000

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

Closed
zhopan77 opened this issue Dec 4, 2014 · 6 comments · Fixed by #9022
Closed

Timestamp('now', tz=xxx) result wrong #9000

zhopan77 opened this issue Dec 4, 2014 · 6 comments · Fixed by #9022
Labels
Bug Datetime Datetime data dtype Timezones Timezone data dtype
Milestone

Comments

@zhopan77
Copy link

zhopan77 commented Dec 4, 2014

In earlier version (0.14 and earlier), Timestamp('now', tz=xxx) will return time now in xxx time zone.

In 0.15.1, it returns the time in UTC but tagged with xxx time zone.

Example:

In version 0.12.0:

import pandas
pandas.version.version
'0.12.0'
pandas.Timestamp('now', tz='US/Central')
Timestamp('2014-12-04 12:06:03-0600', tz='US/Central')
pandas.Timestamp('now')
Timestamp('2014-12-04 18:06:11', tz=None)

In version 0.15.1:

import pandas
pandas.version.version
'0.15.1'
pandas.Timestamp('now', tz='US/Central')
Timestamp('2014-12-04 18:07:29-0600', tz='US/Central')
pandas.Timestamp('now')
Timestamp('2014-12-04 18:07:37')

@jreback
Copy link
Contributor

jreback commented Dec 4, 2014

this should return exactly what datetime.now(tz) returns. https://docs.python.org/2/library/datetime.html#datetime-objects

In [10]: import pytz

In [11]: tz = pytz.timezone('US/Eastern')

In [12]: tz
Out[12]: <DstTzInfo 'US/Eastern' LMT-1 day, 19:04:00 STD>

In [13]: datetime.now()
Out[13]: datetime.datetime(2014, 12, 4, 18, 27, 9, 211050)

In [14]: Timestamp.now()
Out[14]: Timestamp('2014-12-04 18:27:11.883002')

In [15]: datetime.now(tz)
Out[15]: datetime.datetime(2014, 12, 4, 18, 27, 15, 514437, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>)

In [16]: Timestamp.now(tz)
Out[16]: Timestamp('2014-12-04 18:27:20.778796-0500', tz='US/Eastern')

In [17]: Timestamp(datetime.now(tz))
Out[17]: Timestamp('2014-12-04 18:28:17.047905-0500', tz='US/Eastern')

looks correct to me (and IIRC 0.12 was wrong)

@jreback jreback added Timezones Timezone data dtype Datetime Datetime data dtype Usage Question labels Dec 4, 2014
@rockg
Copy link
Contributor

rockg commented Dec 5, 2014

I think the issue is with Timestamp('now') which I didn't even know was a possibility.

Timestamp.now()
Out[7]: Timestamp('2014-12-04 20:57:54.425729')
Timestamp('now')
Out[8]: Timestamp('2014-12-05 01:58:39')

@rockg
Copy link
Contributor

rockg commented Dec 5, 2014

@jreback
Copy link
Contributor

jreback commented Dec 5, 2014

from pandas/src/numpy_datetime_strings.c

is where this is parsed. So that's a UTC time, which is then has a tz tacked on. I think this needs to indicate is UTC when passed back

 * Parses (almost) standard ISO 8601 date strings. The differences are:
 *
 * + The date "20100312" is parsed as the year 20100312, not as
 *   equivalent to "2010-03-12". The '-' in the dates are not optional.
 * + Only seconds may have a decimal point, with up to 18 digits after it
 *   (maximum attoseconds precision).
 * + Either a 'T' as in ISO 8601 or a ' ' may be used to separate
 *   the date and the time. Both are treated equivalently.
 * + Doesn't (yet) handle the "YYYY-DDD" or "YYYY-Www" formats.
 * + Doesn't handle leap seconds (seconds value has 60 in these cases).
 * + Doesn't handle 24:00:00 as synonym for midnight (00:00:00) tomorrow
 * + Accepts special values "NaT" (not a time), "Today", (current
 *   day according to local time) and "Now" (current time in UTC).

@jreback jreback added Bug and removed Usage Question labels Dec 5, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 5, 2014
@rockg
Copy link
Contributor

rockg commented Dec 6, 2014

I certainly think that we should change the behavior of 'now' to be consistent with .now. It doesn't make sense to be different. Agreed?

@jreback
Copy link
Contributor

jreback commented Dec 6, 2014

yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants