Skip to content

Commit 2099494

Browse files
SG-37924 Replace utcfromtimestamp for Python 3.12 (#390)
* Replace `utcfromtimestamp` for Python 3.12 * Support expected value
1 parent cfab2b4 commit 2099494

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/test_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,12 @@ def test_transform_data(self):
587587
now = datetime.datetime.fromtimestamp(timestamp).replace(
588588
microsecond=0, tzinfo=SG_TIMEZONE.local
589589
)
590-
utc_now = datetime.datetime.utcfromtimestamp(timestamp).replace(microsecond=0)
590+
utc_now = (
591+
datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)
592+
.replace(microsecond=0)
593+
.astimezone(None)
594+
.replace(tzinfo=None)
595+
)
591596
local = {"date": now.strftime("%Y-%m-%d"), "datetime": now, "time": now.time()}
592597
# date will still be the local date, because they are not transformed
593598
utc = {

0 commit comments

Comments
 (0)