New submission from Mirko Vogt:

I trapped into a pitfall today with web programming using DateTime.isoformat() 
in the backend and Javascript on the frontend side.

isoformat() string'yfies a DateTime-object according to ISO 8601, which states 
that, if no timezone is specified, the string is supposed to be interpreted as 
UTC implicitly. isoformat() doesn't append any TZ if the object is UTC - so far 
so good.

However when interacting with JavaScript that leads to errors, as the 
ECMAScript ed 6 draft states (and most browser act like that): "date time 
strings without a time zone are to be treated as local, not UTC)."[1]

That is not Python's fault - however considering the issues this behaviour 
could cause as well as following the philosophy 'explicit is better than 
implicit', I'd suggest explicitly marking UTC-strings as such by adding a 
trailing 'Z'. According ISO 8601 that is totally fine, optional though.

[1]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

----------
messages: 234829
nosy: mirkovogt
priority: normal
severity: normal
status: open
title: datetime.isoformat() -> explicitly mark UTC string as such
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23332>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to