Skip to content

Commit 54a7116

Browse files
committed
using time.localtime
1 parent d07b4ad commit 54a7116

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/test/test_zipfile/test_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,14 +1784,14 @@ def test_writestr_extended_local_header_issue1202(self):
17841784
def test_write_with_source_date_epoch(self):
17851785
with os_helper.EnvironmentVarGuard() as env:
17861786
# Set the SOURCE_DATE_EPOCH environment variable to a specific timestamp
1787-
env['SOURCE_DATE_EPOCH'] = "1727440508"
1787+
env['SOURCE_DATE_EPOCH'] = "1735715999"
17881788

17891789
with zipfile.ZipFile(TESTFN, "w") as zf:
17901790
zf.writestr("test_source_date_epoch.txt", "Testing SOURCE_DATE_EPOCH")
17911791

17921792
with zipfile.ZipFile(TESTFN, "r") as zf:
17931793
zip_info = zf.getinfo("test_source_date_epoch.txt")
1794-
get_time = time.gmtime(int(os.environ['SOURCE_DATE_EPOCH']))[:6]
1794+
get_time = time.localtime(int(os.environ['SOURCE_DATE_EPOCH']))[:6]
17951795
# Compare each element of the date_time tuple
17961796
# Allow for a 1-second difference
17971797
for z_time, g_time in zip(zip_info.date_time, get_time):
@@ -1806,7 +1806,7 @@ def test_write_without_source_date_epoch(self):
18061806

18071807
with zipfile.ZipFile(TESTFN, "r") as zf:
18081808
zip_info = zf.getinfo("test_no_source_date_epoch.txt")
1809-
current_time = time.gmtime()[:6]
1809+
current_time = time.localtime()[:6]
18101810
for z_time, c_time in zip(zip_info.date_time, current_time):
18111811
self.assertAlmostEqual(z_time, c_time, delta=1)
18121812

Lib/zipfile/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def _for_archive(self, archive: ZipFile) -> Self:
617617
# gh-91279: Set the SOURCE_DATE_EPOCH to a specific timestamp
618618
epoch = os.environ.get('SOURCE_DATE_EPOCH')
619619
get_time = int(epoch) if epoch else time.time()
620-
self.date_time = time.gmtime(get_time)[:6]
620+
self.date_time = time.localtime(get_time)[:6]
621621

622622
self.compress_type = archive.compression
623623
self.compress_level = archive.compresslevel

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy