Skip to content

Commit dbbab8f

Browse files
authored
Source Dixa: Pin tz in ConversationExport.ms_timestamp_to_datetime (#4696)
1 parent 4863ea1 commit dbbab8f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

airbyte-integrations/connectors/source-dixa/source_dixa/source.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
from abc import ABC
27-
from datetime import datetime, timedelta
27+
from datetime import datetime, timedelta, timezone
2828
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
2929

3030
import requests
@@ -60,7 +60,9 @@ def ms_timestamp_to_datetime(milliseconds: int) -> datetime:
6060
"""
6161
Converts a millisecond-precision timestamp to a datetime object.
6262
"""
63-
return datetime.fromtimestamp(ConversationExport._validate_ms_timestamp(milliseconds) / 1000)
63+
return datetime.fromtimestamp(
64+
ConversationExport._validate_ms_timestamp(milliseconds) / 1000, tz=timezone.utc
65+
)
6466

6567
@staticmethod
6668
def datetime_to_ms_timestamp(dt: datetime) -> int:

airbyte-integrations/connectors/source-dixa/unit_tests/unit_test.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,29 @@ def test_validate_ms_timestamp_with_invalid_input_length():
4949

5050
def test_ms_timestamp_to_datetime():
5151
assert ConversationExport.ms_timestamp_to_datetime(1625312980123) == datetime(
52-
year=2021, month=7, day=3, hour=13, minute=49, second=40, microsecond=123000
52+
year=2021,
53+
month=7,
54+
day=3,
55+
hour=11,
56+
minute=49,
57+
second=40,
58+
microsecond=123000,
59+
tzinfo=timezone.utc
5360
)
5461

5562

5663
def test_datetime_to_ms_timestamp():
5764
assert (
58-
ConversationExport.datetime_to_ms_timestamp(datetime(year=2021, month=7, day=3, hour=13, minute=49, second=40, microsecond=123000))
65+
ConversationExport.datetime_to_ms_timestamp(datetime(
66+
year=2021,
67+
month=7,
68+
day=3,
69+
hour=11,
70+
minute=49,
71+
second=40,
72+
microsecond=123000,
73+
tzinfo=timezone.utc)
74+
)
5975
== 1625312980123
6076
)
6177

0 commit comments

Comments
 (0)