Skip to content

archive/zip: record time stamps in "Extended Timestamp Extra Field" #10242

Description

@mattn
    out, err := ioutil.TempFile(os.TempDir(), "zip")
    if err != nil {
        t.Fatal("creating:", err)
    }
    zw := NewWriter(out)

    in, err := os.Open("writer_test.go")
    if err != nil {
        t.Fatal("opening:", err)
    }
    info, err := in.Stat()
    if err != nil {
        t.Fatal("stat:", err)
    }
    ftime := info.ModTime().Unix()

    header, err := FileInfoHeader(info)
    if err != nil {
        t.Fatal("FileInfoHeader:", err)
    }
    header.Name = info.Name()
    zf, err := zw.CreateHeader(header)
    if err != nil {
        t.Fatal("CreateHeader:", err)
    }
    if _, err = io.Copy(zf, in); err != nil {
        t.Fatal("copying:", err)
    }
    in.Close()
    zw.Close()
    out.Close()

timestamp of the file in the zip, is UTC timezone. So +9 hours in my location.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions