From 7f35600b28522a84aba318cf2c441429d7b8be47 Mon Sep 17 00:00:00 2001 From: W-Mark Kubacki Date: Mon, 18 Apr 2016 23:33:47 +0200 Subject: [PATCH] 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. --- middleware/browse/browse.go | 2 +- middleware/browse/browse_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware/browse/browse.go b/middleware/browse/browse.go index a21b23040..d75b2acad 100644 --- a/middleware/browse/browse.go +++ b/middleware/browse/browse.go @@ -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(), }) } diff --git a/middleware/browse/browse_test.go b/middleware/browse/browse_test.go index c87925242..0363d2f41 100644 --- a/middleware/browse/browse_test.go +++ b/middleware/browse/browse_test.go @@ -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) }