mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(utils): datetime_to_epoch function is fixed to timezone aware epoch (#37979)
This commit is contained in:
committed by
GitHub
parent
cbf153845e
commit
440602ef34
@@ -24,7 +24,7 @@ EPOCH = datetime(1970, 1, 1)
|
||||
def datetime_to_epoch(dttm: datetime) -> float:
|
||||
"""Convert datetime to milliseconds to epoch"""
|
||||
if dttm.tzinfo:
|
||||
dttm = dttm.replace(tzinfo=pytz.utc)
|
||||
dttm = dttm.astimezone(pytz.utc)
|
||||
epoch_with_tz = pytz.utc.localize(EPOCH)
|
||||
return (dttm - epoch_with_tz).total_seconds() * 1000
|
||||
return (dttm - EPOCH).total_seconds() * 1000
|
||||
|
||||
Reference in New Issue
Block a user