mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-16 13:08:55 +00:00
[utils] Add microseconds to unified_timestamp
This commit is contained in:
@@ -1843,7 +1843,7 @@ def unified_strdate(date_str, day_first=True):
|
||||
return str(upload_date)
|
||||
|
||||
|
||||
def unified_timestamp(date_str, day_first=True):
|
||||
def unified_timestamp(date_str, day_first=True, with_milliseconds=False):
|
||||
if date_str is None:
|
||||
return None
|
||||
|
||||
@@ -1869,7 +1869,7 @@ def unified_timestamp(date_str, day_first=True):
|
||||
for expression in date_formats(day_first):
|
||||
with contextlib.suppress(ValueError):
|
||||
dt = datetime.datetime.strptime(date_str, expression) - timezone + datetime.timedelta(hours=pm_delta)
|
||||
return calendar.timegm(dt.timetuple())
|
||||
return calendar.timegm(dt.timetuple()) + (dt.microsecond/1e6 if with_milliseconds else 0)
|
||||
|
||||
timetuple = email.utils.parsedate_tz(date_str)
|
||||
if timetuple:
|
||||
|
||||
Reference in New Issue
Block a user