mirror of
https://github.com/apache/superset.git
synced 2026-04-21 09:04:38 +00:00
* Allow running multiple statements from SQL Lab * fix tests * More tests * merge heads * fix heads
18 lines
398 B
Python
18 lines
398 B
Python
from datetime import datetime
|
|
|
|
import pytz
|
|
|
|
EPOCH = datetime(1970, 1, 1)
|
|
|
|
|
|
def datetime_to_epoch(dttm):
|
|
if dttm.tzinfo:
|
|
dttm = dttm.replace(tzinfo=pytz.utc)
|
|
epoch_with_tz = pytz.utc.localize(EPOCH)
|
|
return (dttm - epoch_with_tz).total_seconds() * 1000
|
|
return (dttm - EPOCH).total_seconds() * 1000
|
|
|
|
|
|
def now_as_float():
|
|
return datetime_to_epoch(datetime.utcnow())
|