Should DATETIME values be returned as datetime objects instead of string
Created by: Florian Spreckelsen
Right now, a property with CaosDB datatype DATETIME
has a string value when with the python client. Should this be a datetime.datetime object instead?
Currently, extensive treatment of datetime properties is done in advancedtools.cfood. This should be prevented.
Imported comments:
By Timm Fitschen on 2021-02-10T12:19:48.715Z
Yes, but stay configurable to use/fall-back to strings, because otherwise not all datetime values would be supported by caosdb-pylib
By Henrik tom Wörden on 2020-10-09T08:19:33.750Z
mentioned in merge request caosdb-advanced-user-tools!54 (merged)
By Henrik tom Wörden on 2020-10-09T08:17:36.135Z
mentioned in issue #37 (closed)
By Henrik tom Wörden on 2020-08-31T11:43:42.868Z
In [1]: from datetime import datetime
In [2]: datetime.now().toisoformat()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-0a0df3429f39> in <module>
----> 1 datetime.now().toisoformat()
AttributeError: 'datetime.datetime' object has no attribute 'toisoformat'
In [3]: datetime.fromisoformat("2020-04-04T22:15:10.023422+0030")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-15668ee64a75> in <module>
----> 1 datetime.fromisoformat("2020-04-04T22:15:10.023422+0030")
ValueError: Invalid isoformat string: '2020-04-04T22:15:10.023422+0030'
In [4]: datetime.fromisoformat("2020-04-04T22:15:10.023422")
Out[4]: datetime.datetime(2020, 4, 4, 22, 15, 10, 23422)
In [5]: datetime.fromisoformat("2020-04-04T22:15:10.023422+00:30")
Out[5]: datetime.datetime(2020, 4, 4, 22, 15, 10, 23422, tzinfo=datetime.timezone(datetime.timedelta(seconds=1800)))
By Henrik tom Wörden on 2020-08-31T10:29:09.561Z
changed the description