Skip to content

UTC Date not converted to Local if in Folder #422

Description

@philip-firstorder

I archived a a file with modified date 2019-06-25 11:58:57.201 +0000 UTC using https://golang.org/pkg/archive/zip/

If I put the file inside a folder and the folder is archived, then the UTC date is not converted to Local Date when unarchiving, to reproduce you can unarchive this png.
Bad Date.zip

Bad UTC Date

But if the file is directly archived in the root, then the date is correctly converted to Local Date.
Correct Date.zip

The correct time using my Germany local +2 Timezone should be 13:58, but if the file is inside a folder it remains 11:58 when unarchived, seems a bug to me.

$ zipinfo -v "Bad Date.zip"

Archive:  Bad Date.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                     30923 (00000000000078CBh)
  Actual end-cent-dir record offset:         30898 (00000000000078B2h)
  Expected end-cent-dir record offset:       30898 (00000000000078B2h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 2 entries.
  The central directory is 189 (00000000000000BDh) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 30709 (00000000000077F5h).


Central directory entry #1:
---------------------------

  Folder/

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             none (stored)
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2019 Jun 25 16:45:54
  file last modified on (UT extra field modtime): 2019 Jun 25 18:45:54 local
  file last modified on (UT extra field modtime): 2019 Jun 25 16:45:54 UTC
  32-bit CRC value (hex):                         00000000
  compressed size:                                0 bytes
  uncompressed size:                              0 bytes
  length of filename:                             7 characters
  length of extra field:                          9 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification time.

  There is no file comment.

Central directory entry #2:
---------------------------

  Folder/firstorder-black.png

  offset of local header from start of archive:   46
                                                  (000000000000002Eh) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             none (stored)
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2019 Jun 25 11:58:56
  file last modified on (UT extra field modtime): 2019 Jun 25 13:58:57 local
  file last modified on (UT extra field modtime): 2019 Jun 25 11:58:57 UTC
  32-bit CRC value (hex):                         5c46ba63
  compressed size:                                30581 bytes
  uncompressed size:                              30581 bytes
  length of filename:                             27 characters
  length of extra field:                          9 bytes
  length of file comment:                         45 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification time.

------------------------- file comment begins ----------------------------
5d013b72409327f33177b5ab/firstorder-black.png
-------------------------- file comment ends -----------------------------
zipinfo -v "Correct Date.zip"

Archive:  Correct Date.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                     30798 (000000000000784Eh)
  Actual end-cent-dir record offset:         30776 (0000000000007838h)
  Expected end-cent-dir record offset:       30776 (0000000000007838h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 1 entry.
  The central directory is 120 (0000000000000078h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 30656 (00000000000077C0h).


Central directory entry #1:
---------------------------

  firstorder-black.png

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             none (stored)
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2019 Jun 25 11:58:56
  file last modified on (UT extra field modtime): 2019 Jun 25 13:58:57 local
  file last modified on (UT extra field modtime): 2019 Jun 25 11:58:57 UTC
  32-bit CRC value (hex):                         5c46ba63
  compressed size:                                30581 bytes
  uncompressed size:                              30581 bytes
  length of filename:                             20 characters
  length of extra field:                          9 bytes
  length of file comment:                         45 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification time.

------------------------- file comment begins ----------------------------
5d013b72409327f33177b5ab/firstorder-black.png
-------------------------- file comment ends -----------------------------

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions