browse: Emit datetime in UTC instead of the server's timezone

Makes sure the view is the same no matter where a site is hosted.
This commit is contained in:
W-Mark Kubacki 2016-04-18 23:33:47 +02:00
parent cc6aa6b54b
commit 7f35600b28
2 changed files with 2 additions and 2 deletions

View File

@ -217,7 +217,7 @@ func directoryListing(files []os.FileInfo, canGoUp bool, urlPath string) (Listin
Name: f.Name(),
Size: f.Size(),
URL: url.String(),
ModTime: f.ModTime(),
ModTime: f.ModTime().UTC(),
Mode: f.Mode(),
})
}

View File

@ -238,7 +238,7 @@ func TestBrowseJson(t *testing.T) {
// Tests fail in CI environment because all file mod times are the same for
// some reason, making the sorting unpredictable. To hack around this,
// we ensure here that each file has a different mod time.
chTime := f.ModTime().Add(-(time.Duration(i) * time.Second))
chTime := f.ModTime().UTC().Add(-(time.Duration(i) * time.Second))
if err := os.Chtimes(filepath.Join(testDataPath, name), chTime, chTime); err != nil {
t.Fatal(err)
}