mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
use jc.utils.timestamp instead of jc.utils.parse_datetime_to_timestamp()
This commit is contained in:
@ -154,11 +154,11 @@ def parse(data, raw=False, quiet=False):
|
|||||||
dt = None
|
dt = None
|
||||||
dt_utc = None
|
dt_utc = None
|
||||||
|
|
||||||
timestamp = jc.utils.parse_datetime_to_timestamp(data)
|
timestamp = jc.utils.timestamp(data)
|
||||||
if timestamp['timestamp_naive']:
|
if timestamp.naive:
|
||||||
dt = datetime.fromtimestamp(timestamp['timestamp_naive'])
|
dt = datetime.fromtimestamp(timestamp.naive)
|
||||||
if timestamp['timestamp_utc']:
|
if timestamp.utc:
|
||||||
dt_utc = datetime.fromtimestamp(timestamp['timestamp_utc'], timezone.utc)
|
dt_utc = datetime.fromtimestamp(timestamp.utc, timezone.utc)
|
||||||
|
|
||||||
if dt_utc:
|
if dt_utc:
|
||||||
dt = dt_utc
|
dt = dt_utc
|
||||||
@ -180,9 +180,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
'day_of_year': int(dt.strftime('%j')),
|
'day_of_year': int(dt.strftime('%j')),
|
||||||
'week_of_year': int(dt.strftime('%W')),
|
'week_of_year': int(dt.strftime('%W')),
|
||||||
'iso': dt.isoformat(),
|
'iso': dt.isoformat(),
|
||||||
'epoch': timestamp['timestamp_naive'],
|
'epoch': timestamp.naive,
|
||||||
'epoch_utc': timestamp['timestamp_utc'],
|
'epoch_utc': timestamp.utc,
|
||||||
'timezone_aware': True if timestamp['timestamp_utc'] else False
|
'timezone_aware': True if timestamp.utc else False
|
||||||
}
|
}
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
|
Reference in New Issue
Block a user