Skip to content

API: provide compat for Timestamp now/today/utcnow class methods (GH5339) #5342

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

Merged
merged 1 commit into from
Oct 27, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Oct 26, 2013

closes #5339

@@ -140,6 +140,22 @@ class Timestamp(_Timestamp):
note: by definition there cannot be any tz info on the ordinal itself """
return cls(datetime.fromordinal(ordinal),offset=offset,tz=tz)

@classmethod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat, didn't know you could use decorators in Cython at all...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep u can use them to tell cython not to check array bounds too, for example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right the 'fake' cython decorators.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are real. like u said, cython implements decorators. i think cython is a superset of python so all of python is implemented, with the exception of assignment in the body of a class.

@jreback
Copy link
Contributor Author

jreback commented Oct 26, 2013

cc @JanSchulz , cc @Cancan01 any other methods you think are missing?

@cancan101
Copy link
Contributor

@jreback it's cancan101 !

@cancan101
Copy link
Contributor

fromtimestamp, utcfromtimestamp, strptime and combine are also broken.

@jreback
Copy link
Contributor Author

jreback commented Oct 26, 2013

@cancan101 sorry...typo!

@jreback
Copy link
Contributor Author

jreback commented Oct 26, 2013

@cancan101 ...want to add them? should be straightforward...just add tests and push to this PR!

@jreback
Copy link
Contributor Author

jreback commented Oct 27, 2013

@cancan101 pls create a new issue for these other methods

jreback added a commit that referenced this pull request Oct 27, 2013
API: provide compat for Timestamp  now/today/utcnow class methods (GH5339)
@jreback jreback merged commit f41c102 into pandas-dev:master Oct 27, 2013
""" compat now with datetime """
if isinstance(tz, basestring):
tz = pytz.timezone(tz)
return cls(datetime.now(tz))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpcloud so is this the right option here? Or should it just be "cls('now')"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fine the way it is and that would depend on dateutil parsing i think. i'd prefer to just depend on stdlib here ... but not super strong about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what datetime does

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep ... looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timestamp.now() throws an Error
4 participants