1
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-05-20 17:45:45 -05:00

cleaner formula

Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
This commit is contained in:
Mozi 2025-01-07 10:37:38 +00:00
parent 5b6ad82dae
commit 58f7f5479b

View file

@ -1390,7 +1390,7 @@ def datetime_round(dt_, precision='day'):
'second': 1,
}
roundto = lambda x, n: ((x + n / 2) // n) * n
timestamp = roundto(calendar.timegm(dt_.timetuple()) * time_scale + dt_.microsecond, unit_seconds[precision] * time_scale) / time_scale
timestamp = roundto(calendar.timegm(dt_.timetuple()) + dt_.microsecond / time_scale, unit_seconds[precision])
return datetime_from_timestamp(timestamp)