Skip to content

Commit

Permalink
Merge pull request #3208 from vvoland/fix-datetime_to_timestamp
Browse files Browse the repository at this point in the history
utils: Fix datetime_to_timestamp
  • Loading branch information
thaJeztah committed Jan 3, 2024
2 parents 3ec5a68 + 1784cc2 commit f467fd9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os.path
import shlex
import string
from datetime import datetime
from datetime import datetime, timezone
from packaging.version import Version

from .. import errors
Expand Down Expand Up @@ -394,8 +394,8 @@ def convert_filters(filters):


def datetime_to_timestamp(dt):
"""Convert a UTC datetime to a Unix timestamp"""
delta = dt - datetime.utcfromtimestamp(0)
"""Convert a datetime to a Unix timestamp"""
delta = dt.astimezone(timezone.utc) - datetime(1970, 1, 1, tzinfo=timezone.utc)
return delta.seconds + delta.days * 24 * 3600


Expand Down

0 comments on commit f467fd9

Please sign in to comment.