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
message.header.date should specify a timezone #143
Comments
Hum, the alternative is to use But good point. |
Actually, |
see, for reference, the difference in the two print statements from this snippet: from datetime import datetime, timedelta, tzinfo
TDZERO = timedelta(0)
class UTC(tzinfo):
"""A UTC tzinfo class"""
def utcoffset(self, dt):
return TDZERO
def tzname(self, dt):
return 'UTC'
def dst(self, dt):
return TDZERO
utc = UTC()
print('utcnow', datetime.utcnow().isoformat())
print('tz=utc', datetime.now(tz=utc).isoformat()) gives
|
Sorry I was unclear in my statement, we could normalize the spec saying that the date time should be UTC if the current spec is not precise enough. |
Right, gotcha. Still, I think it's worth adding the timezone to the string values as well, rather than just altering the spec to allow people to assume they're in UTC - after all Explicit is better than implicit 😉 |
We already have three copies of the machinery to produce tz-aware UTC timestamps - there's one in jupyter_client, but it's currently in the tests ( |
Oh absolutely, utc is the way forward, I just meant the offset (of zero, naturally) should get included in the json-ified text version, as with the |
Do I smell a Pull Request coming ? |
Haha 😆 I'm happy to submit one, I was a little apprehensive of adding yet another mechanism to produce tz-aware timestamps! If you guys know where you'd like to put it, I'll be happy to fix it up... |
We can have nice tz-aware utc timestamps with the stdlib in Python 3 with:
Python 2, of course, needs an backport of the trivial UTC timezone, which we have implemented here (and elsewhere). We can use utc for that, I suppose. |
master (will be 5.0) uses timezone-aware datetimes. |
This came up from ipython-contrib/jupyter_contrib_nbextensions#549, where the lack of timezone causes problems for any javascript trying to use the
date
value. I'm not super sure where thedate
field is added to the header, but assume it's either in jupyter_client/adapter.py#L387-L388 or in jupyter_client/jsonutil.py#L75-L80 - so apologies if this issue should actually be somewhere else.Could the above calls be modified to use something like
❓
The text was updated successfully, but these errors were encountered: