Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckySting committed May 1, 2024
1 parent 1ce7dd3 commit 8bc388b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ydb/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

_SECONDS_IN_DAY = 60 * 60 * 24
_EPOCH = datetime(1970, 1, 1)
_EPOCH_UTC = datetime(1970, 1, 1, tzinfo=timezone.utc)


def _from_date(x: ydb_value_pb2.Value, table_client_settings: table.TableClientSettings) -> typing.Union[date, int]:
Expand Down Expand Up @@ -91,7 +92,7 @@ def _from_timestamp(
def _to_timestamp(pb: ydb_value_pb2.Value, value: typing.Union[datetime, int]):
if isinstance(value, datetime):
if value.tzinfo:
epoch = _EPOCH.replace(tzinfo=timezone.utc)
epoch = _EPOCH_UTC
else:
epoch = _EPOCH
pb.uint64_value = _timedelta_to_microseconds(value - epoch)
Expand Down

0 comments on commit 8bc388b

Please sign in to comment.