pytoml
pytoml copied to clipboard
datetime issue
python 3.4.3, pytoml==0.1.7
>>> import pytoml as toml
>>> import datetime
>>> d={'dt':datetime.datetime.now()}
>>> d
{'dt': datetime.datetime(2016, 2, 25, 11, 18, 17, 536767)}
>>> toml.dumps(d)
'dt = 2016-02-25T11:18:17.536767Z\n'
>>> toml.loads(toml.dumps(d))
{'dt': datetime.datetime(2016, 2, 25, 11, 18, 17, 536767, tzinfo=<pytoml.parser._TimeZone object at 0x7f9aca381978>)}
>>> d == toml.loads(toml.dumps(d))
False
TOML 0.4 only allowed datetimes with timezone information attached - what Python calls a "datetime aware" datetime. When you dump a "naive" timezone, with no timezone info, it looks like pytoml opts to treat that as meaning UTC.
TOML 1.0 (not out yet) adds a separate 'local datetime' type for timestamps without timezone information. https://github.com/toml-lang/toml/pull/414
Thanks for the issue!
As @takluyver points out, this is not a bug, pytoml accepts naive datetimes only as a convenience. Adding compliance with 1.0 would be a new feature and I'm not working on those anymore. Feel free to send a PR though!