Unidata / cftime

Time-handling functionality from netcdf4-python.
https://unidata.github.io/cftime
MIT License
75 stars 39 forks source link

Partial datetime string parsing in cftime #51

Open spencerahill opened 6 years ago

spencerahill commented 6 years ago

Recently in the xarray mailing list (here) and in aospy (here) the need has arisen for the partial datetime string parsing that is currently implemented in xarray as private API, which we therefore don't want to rely on. @spencerkclark argued, and I think I agree, that this functionality is outside the scope of xarray in terms of making it public API.

Separately, @mcgibbon raised the notion of porting it to cftime, which I like the idea of also. Does this seem reasonable? It seems like such a common datetime-related need that it would well fit in the scope of cftime.

CC: @shoyer for any thoughts from the xarray side

shoyer commented 6 years ago

Yes, this definitely belong logically in cftime :)

shoyer commented 6 years ago

I think we are the only authors of this code (OK, technically Google owns what I wrote), so there should be no problem redistributing it under the cftime license.

jswhit commented 6 years ago

@spencerahill, are there any plans to submit a pull request for this?

spencerahill commented 6 years ago

@jswhit I am on travel for several weeks and then under a really pressing deadline through Nov. 1, so unfortunately the earliest I would be able to get to this is sometime in November. But I'm happy to do so then. I invite someone else to do it in the meantime if there is an immediate need.

jswhit commented 6 years ago

OK, I will leave it open

spencerahill commented 5 years ago

What would the API be for this? A cftime.strptime function, akin to datetime.strptime? The relevant code in xarray has parse_iso8601, _parse_iso8601_with_reso, and _parsed_string_to_bounds functions.

shoyer commented 5 years ago

Honestly it's probably fine to keep much of this in xarray. cftime.strptime feels like a nice abstraction to add here, though.

On Tue, Dec 18, 2018 at 1:13 PM Spencer Hill notifications@github.com wrote:

What would the API be for this? A cftime.strptime function, akin to datetime.strptime https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime? The relevant code in xarray https://github.com/pydata/xarray/blob/9c8005937556211a8bf28a946744da3768846c5a/xarray/coding/cftimeindex.py#L12-L100 has parse_iso8601, _parse_iso8601_with_reso, and _parsed_string_to_bounds functions.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/cftime/issues/51#issuecomment-448372480, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKS1gHNj_0Rqpdkvjq7TmrgJUsq4lVAks5u6VpogaJpZM4UXM1m .

swartn commented 3 months ago

Extending on this, we have the need to use cftime and related logic in a project (including partial strings), but we do not need any other xarray functionality. So we have been adapting some of the xarray logic for essentially dealing with cftime partial strings and offsets / timedeltas. At least within our team, we concluded it would be helpful to have some of that functionality available in cftime, for those who need to deal with these kind of dates, but do not need xarray. I'm not sure of the feeling on this - but if there was interest, we could consider directing some effort to making a PR to cftime.