diff --git a/src/celpy/celtypes.py b/src/celpy/celtypes.py index 29742a9..8f0bba0 100644 --- a/src/celpy/celtypes.py +++ b/src/celpy/celtypes.py @@ -1098,7 +1098,10 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}({str(self)!r})" def __str__(self) -> str: - return self.strftime("%Y-%m-%dT%H:%M:%SZ") + text = self.strftime("%Y-%m-%dT%H:%M:%S%z") + if text.endswith("+0000"): + return f"{text[:-5]}Z" + return f"{text[:-2]}:{text[-2:]}" def __add__(self, other: Any) -> 'TimestampType': """Timestamp + Duration -> Timestamp""" diff --git a/tests/test_celtypes.py b/tests/test_celtypes.py index b89e4f4..05bbf02 100644 --- a/tests/test_celtypes.py +++ b/tests/test_celtypes.py @@ -339,6 +339,17 @@ def test_timestamp_type(): assert ts_1.getSeconds() == IntType(30) +def test_timestamp_type_issue_28(): + utc = TimestampType('2020-10-20T12:00:00Z') + not_utc = TimestampType('2020-10-20T12:00:00-05:00') + + assert repr(utc) == "TimestampType('2020-10-20T12:00:00Z')" + assert repr(not_utc) == "TimestampType('2020-10-20T12:00:00-05:00')" + + assert utc != not_utc + assert str(utc) != str(not_utc) + + def test_extended_timestamp_type(): others = { 'et': 'US/Eastern', diff --git a/type_check/lineprecision.txt b/type_check/lineprecision.txt index 10930f0..6eafec4 100644 --- a/type_check/lineprecision.txt +++ b/type_check/lineprecision.txt @@ -5,7 +5,7 @@ celpy.__main__ 465 172 7 42 244 0 celpy.adapter 137 35 3 9 85 5 celpy.c7nlib 1584 340 15 154 1075 0 celpy.celparser 402 208 2 23 169 0 -celpy.celtypes 1500 435 14 221 791 39 +celpy.celtypes 1503 438 14 221 791 39 celpy.evaluation 2471 839 33 176 1408 15 xlate 0 0 0 0 0 0 xlate.c7n_to_cel 1730 387 102 145 1091 5