home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 672825107

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/4337#issuecomment-672825107 https://api.github.com/repos/pydata/xarray/issues/4337 672825107 MDEyOklzc3VlQ29tbWVudDY3MjgyNTEwNw== 6628425 2020-08-12T11:52:13Z 2020-08-12T11:52:13Z MEMBER

Thanks @aidanheerdegen, at least part of this issue may be better discussed in the cftime repository. This seems like a cftime bug: ``` In [1]: import cftime

In [2]: cftime.datetime(1, 1, 1).strftime("%Y-%m-%dT%H:%M:%S") Out[2]: ' 1-01-01T00:00:00' Following Python standard library conventions for `strftime`, the year should be zero-padded: In [3] import datetime

In [4]: datetime.datetime(1, 1, 1).strftime("%Y-%m-%dT%H:%M:%S") Out[4]: '0001-01-01T00:00:00' ISO-8601 formatting [requires zero-padding for years < 1000](https://en.wikipedia.org/wiki/ISO_8601#Years), which due to the bug above cannot currently be achieved easily with `strftime`. Note you may find the `isoformat` method of `cftime.datetime` objects helpful, which already works as we would like it to: In [5]: cftime.datetime(1, 1, 1).isoformat() Out[5]: '0001-01-01T00:00:00' ```

As for your suggested solution:

It would be good if xarray.cftime_range supported the default strftime format output from cftime.datetime objects. It is confusing that it uses this format with repr but explicitly does not support it.

I'm open to this. It seems reasonable that we could expand the acceptable time formats to include the default string representation of cftime objects (the only difference is a " " datetime separator instead of "T").

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  677307460
Powered by Datasette · Queries took 0.789ms · About: xarray-datasette