June 2019
Beginner to intermediate
770 pages
19h 24m
English
Our formatting of dates doesn't make use of the widely-used ISO standard text format. To be more compatible with other languages, we should properly encode the datetime object in a standard string and parse a standard string.
As we're already treating dates as a special case, this seems to be a sensible implementation. It can be done without too much change to our encoding and decoding. Consider this small change to the encoding:
if isinstance(object, datetime.datetime):
fmt= "%Y-%m-%dT%H:%M:%S"
return dict(
__class__="datetime.datetime.strptime",
__args__=[object.strftime(fmt), fmt],
__kw__={}
)
The encoded output names the static method datetime.datetime.strptime() and provides the argument-encoded datetime ...
Read now
Unlock full access