diff --git a/drivers/189/util.go b/drivers/189/util.go index 45833fde..1bc7a430 100644 --- a/drivers/189/util.go +++ b/drivers/189/util.go @@ -178,7 +178,6 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback, func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) { res := make([]model.Obj, 0) pageNum := 1 - loc, _ := time.LoadLocation("Local") for { var resp Files _, err := d.request("https://cloud.189.cn/api/open/file/listFiles.action", http.MethodGet, func(req *resty.Request) { @@ -200,7 +199,7 @@ func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) { break } for _, folder := range resp.FileListAO.FolderList { - lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05", folder.LastOpTime, loc) + lastOpTime := utils.MustParseCNTime(folder.LastOpTime) res = append(res, &model.Object{ ID: strconv.FormatInt(folder.Id, 10), Name: folder.Name, @@ -209,7 +208,7 @@ func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) { }) } for _, file := range resp.FileListAO.FileList { - lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05", file.LastOpTime, loc) + lastOpTime := utils.MustParseCNTime(file.LastOpTime) res = append(res, &model.ObjThumb{ Object: model.Object{ ID: strconv.FormatInt(file.Id, 10), diff --git a/pkg/utils/time.go b/pkg/utils/time.go new file mode 100644 index 00000000..2f81e200 --- /dev/null +++ b/pkg/utils/time.go @@ -0,0 +1,8 @@ +package utils + +import "time" + +func MustParseCNTime(str string) time.Time { + lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05 -07", str+" +08", time.Local) + return lastOpTime +}