pyorient icon indicating copy to clipboard operation
pyorient copied to clipboard

Parsing dates prior to 1970-01-01

Open jmyslik opened this issue 9 years ago • 1 comments

An unhandled exception is thrown when serializations.py tries to parse a date prior to the beginning of the UNIX era, 1970-01-01. As an example, I have a field called deathDate in a Person object. When this is set to a date later than 1970-01-01 (stored internally as a positive long integer) all is well. Setting is before this date, e.g. 1964-12-01 (negative long integer) throws the unhandled exception at line 329:

collected = datetime.fromtimestamp(float(collected) / 1000)

where collected = -160426800000

I assume this is a ValueError because the collected argument to fromtimestamp is out-of-range.

Any suggestions as to how to repair this or how I can represent dates prior to 1970 in a meaningful way? I tried alter database datetimeformat "yyyy-MM-dd HH:mm:ss GG" to no avail.

jmyslik avatar Jul 14 '16 19:07 jmyslik

I cannot replicate this bug in any way it seems to work well for me, any way the exception will be raised by pure python, If you run the two lines you wrote in a python interpreter collected = datetime.fromtimestamp(float(collected) / 1000) where collected = -160426800000 they raise an exception? maybe it's a different point that explodes?

mogui avatar Oct 04 '16 20:10 mogui