Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/celpy/celtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_celtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion type_check/lineprecision.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading