-
Notifications
You must be signed in to change notification settings - Fork 40
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
Any differences between datetime and phony datetimes? #33
Comments
The built-in datetime only works for years > 1. The 'phony' datetime objects are needed to support other calendars besides proleptic_gregorian, and years < 1. They do not contain all the functionality of the the built-in python datetime objects. |
Ah, the years makes sense. Is there an exhaustive (or even partial) list of what functionality the netcdftime objects do not contain from built-in python datetime objects? |
netcdftime.datetime only has strftime, replace, timetuple, repr, to_tuple, |
|
I'm more curious about what netcdftime.datetime is missing, than in what it has. Could someone answer my question in plain English, if they understand the differences in those terms? I can dir the two and compare myself, but it's a lot of work to go in through code/docstrings and grok what all of these methods are/do. Particularly because the docstrings for these things (including built-in datetime) are not very descriptive. If nobody does, I'll go in and figure it out, and write some documentation so everyone doesn't have to go through this. One example is that built-in datetimes manage timezones, while netcdftime does not. |
I'm telling you what I know. You'll have to compare the methods in python datetime to the methods supplied by netcdf.datetime if you want more. Note that netcdf.datetime will be a python datetime instance in most cases - only if the python datetime object doesn't support the requested calendar or times will a 'phony' datetime instance be returned. It would be pretty easy to write a function to request something like a timezone from the object to determine if it's a python datetime object or not. |
Thank you for sharing what you know! I wasn't trying to passive-aggressively direct my comment at you, I am genuinely asking if there are others looking at this who can give another answer. Maybe @jhamman, @shoyer, @spencerkclark, @ckhroulev or others know more? Like I said, I'll go through the methods (likely regardless of responses here), but there are some things that might not be revealed by doing that. I'd like to get as much feedback as I can. For example, Datetime360Day's I've written my own datetime selector as a workaround for the issue where if the current (or older) versions of netcdf4 are installed, the netcdf4 version of netcdftime will be imported. So I'll always know what type I'm returning. |
I don't think there's much to be done other than looking at the methods right now. Obviously API docs would be nice to have at some point in the future. Offhand, netcdftime does not support timezones or the alternative datetime constructors (like |
@mcgibbon - is there more to discuss here? |
@jhamman the discussion leads me to think someone should open a new issue for writing complete API docs. But I'll close this one, since I got what answers were available. |
Thanks @mcgibbon - additional issues/help developing the documentation would be much appreciated. |
I've written a PR for Sympl (code) to start integrating netcdftime datetime-like objects into Sympl models. Since the documentation is quite sparse and a little vague, I thought I should ask if there are any differences between the built-in datetime and netcdftime's datetime-like objects that I should be aware of and warn users about? You're welcome to comment on the PR directly.
I was also confused as to why there was a DatetimeProlepticGregorian to override the built-in datetime, so I've used the built-in one instead for that calendar option. Any insight into whether this is a good idea would be appreciated.
The text was updated successfully, but these errors were encountered: