Skip to content

Commit b11afd3

Browse files
KentaroJayemmatyping
authored andcommitted
pythongh-133125: Clarify ZipInfo.date_time attribute documentation (python#136082)
Specifically, clarify that ZipInfo.date_time pulls the datetime information from the central directory, and that times are interpreted as local time. Co-authored-by: Emma Smith <emma@emmatyping.dev>
1 parent 8170a31 commit b11afd3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Doc/library/zipfile.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,10 @@ Instances have the following methods and attributes:
830830
.. attribute:: ZipInfo.date_time
831831

832832
The time and date of the last modification to the archive member. This is a
833-
tuple of six values:
833+
tuple of six values representing the "last [modified] file time" and "last [modified] file date"
834+
fields from the ZIP file's central directory.
835+
836+
The tuple contains:
834837

835838
+-------+--------------------------+
836839
| Index | Value |
@@ -850,7 +853,15 @@ Instances have the following methods and attributes:
850853

851854
.. note::
852855

853-
The ZIP file format does not support timestamps before 1980.
856+
The ZIP format supports multiple timestamp fields in different locations
857+
(central directory, extra fields for NTFS/UNIX systems, etc.). This attribute
858+
specifically returns the timestamp from the central directory. The central
859+
directory timestamp format in ZIP files does not support timestamps before
860+
1980. While some extra field formats (such as UNIX timestamps) can represent
861+
earlier dates, this attribute only returns the central directory timestamp.
862+
863+
The central directory timestamp is interpreted as representing local
864+
time, rather than UTC time, to match the behavior of other zip tools.
854865

855866

856867
.. attribute:: ZipInfo.compress_type

0 commit comments

Comments
 (0)