From c5c9b5eda4c7636e1a523b6fb67cc7563641f971 Mon Sep 17 00:00:00 2001 From: Shelton Zhu <498220739@qq.com> Date: Sun, 11 Aug 2024 17:16:07 +0800 Subject: [PATCH] fix: fix timezone bug if missing Asia/Shanghai --- pkg/driver/file.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/driver/file.go b/pkg/driver/file.go index 73099db..118a908 100644 --- a/pkg/driver/file.go +++ b/pkg/driver/file.go @@ -42,7 +42,11 @@ func (f *File) from(fileInfo *FileInfo) *File { f.FileID = fileInfo.FileID f.ParentID = string(fileInfo.CategoryID) f.IsDirectory = false - loc, _ := time.LoadLocation("Asia/Shanghai") // updatetime is a string without timezone + loc, err := time.LoadLocation("Asia/Shanghai") // updatetime is a string without timezone + if err != nil { + // if missing Asia/Shanghai use CST(UTC+8) + loc = time.FixedZone("UTC+8", 8*3600) + } localTime, err := time.ParseInLocation("2006-01-02 15:04", fileInfo.UpdateTime, loc) if err == nil { f.UpdateTime = time.Unix(localTime.Unix(), 0)