cel-python
cel-python copied to clipboard
TimestampType.__str__ doesn't honor timezone offset
When parsing a timestamp (e.g., timestamp("2020-10-20T12:00:00-05:00")), the provided timezone offset is stored but not output by __str__ or __repr__ which are hard coded to output the Z UTC abbreviation.
I think this is just a display issue, as the offset does appear to be used in comparisons. But it can be confusing when playing around in a repl shell. Example:
In [155]: utc = celtypes.TimestampType('2020-10-20T12:00:00Z')
In [156]: not_utc = celtypes.TimestampType('2020-10-20T12:00:00-05:00')
In [157]: utc
Out[157]: TimestampType('2020-10-20T12:00:00Z')
In [158]: not_utc
Out[158]: TimestampType('2020-10-20T12:00:00Z')
In [159]: utc == not_utc
Out[159]: False
In [160]: str(utc) == str(not_utc)
Out[160]: True
This does seem wrong to ignore an actual timezone and treat it as UTC ("Z")