-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
@@ -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 |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
cc @JanSchulz , cc @Cancan01 any other methods you think are missing? |
@jreback it's cancan101 ! |
|
@cancan101 sorry...typo! |
@cancan101 ...want to add them? should be straightforward...just add tests and push to this PR! |
@cancan101 pls create a new issue for these other methods |
API: provide compat for Timestamp now/today/utcnow class methods (GH5339)
""" compat now with datetime """ | ||
if isinstance(tz, basestring): | ||
tz = pytz.timezone(tz) | ||
return cls(datetime.now(tz)) |
There was a problem hiding this comment.
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')
"?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
closes #5339