]> jfr.im git - yt-dlp.git/commitdiff
[utils] Fix `time_seconds` to use the provided TZ (#6118)
authorLesmiscore <redacted>
Tue, 31 Jan 2023 13:30:00 +0000 (22:30 +0900)
committerGitHub <redacted>
Tue, 31 Jan 2023 13:30:00 +0000 (22:30 +0900)
Authored by: Lesmiscore, Grub4K

Fixes https://github.com/yt-dlp/yt-dlp/pull/6056

yt_dlp/utils.py

index 458239a1259270eb84caf323e1c9dd18492c77ad..7d51fe472e10f1bcaf86e00be066d08c174aa42c 100644 (file)
@@ -5585,8 +5585,10 @@ def get_first(obj, keys, **kwargs):
 
 
 def time_seconds(**kwargs):
-    t = datetime.datetime.now(datetime.timezone(datetime.timedelta(**kwargs)))
-    return t.timestamp()
+    """
+    Returns TZ-aware time in seconds since the epoch (1970-01-01T00:00:00Z)
+    """
+    return time.time() + datetime.timedelta(**kwargs).total_seconds()
 
 
 # create a JSON Web Signature (jws) with HS256 algorithm