Skip to content

Commit

Permalink
Fix date parsing having wrong offset
Browse files Browse the repository at this point in the history
  • Loading branch information
iharthi committed Jul 8, 2021
1 parent ef8df76 commit 599e232
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions elvis/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from datetime import datetime, timedelta
from datetime import datetime
import pytz

DATE_PREFIX = '/Date('
DATE_SUFFIX = ')/'

ELVIS_TIMEZONE = pytz.timezone('Europe/Tallinn')
UTC = pytz.timezone('UTC')


def decode_elvis_timestamp(timestamp: str):
Expand All @@ -24,8 +25,8 @@ def decode_elvis_timestamp(timestamp: str):
return timestamp

# Elvis Timezone offsets are relevant to Elvis natural timezone (Tallinn)
return datetime.fromtimestamp(seconds).astimezone(
ELVIS_TIMEZONE
) + timedelta(minutes=timezone_offset)
return ELVIS_TIMEZONE.localize(datetime.fromtimestamp(seconds).astimezone(
pytz.FixedOffset(-timezone_offset)
).replace(tzinfo=None))

return timestamp

0 comments on commit 599e232

Please sign in to comment.