Skip to content

Commit f3a5e37

Browse files
committed
fix(189): force use CN time zone (close #2240)
1 parent 46701a1 commit f3a5e37

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/189/util.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback,
178178
func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) {
179179
res := make([]model.Obj, 0)
180180
pageNum := 1
181-
loc, _ := time.LoadLocation("Local")
182181
for {
183182
var resp Files
184183
_, 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) {
200199
break
201200
}
202201
for _, folder := range resp.FileListAO.FolderList {
203-
lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05", folder.LastOpTime, loc)
202+
lastOpTime := utils.MustParseCNTime(folder.LastOpTime)
204203
res = append(res, &model.Object{
205204
ID: strconv.FormatInt(folder.Id, 10),
206205
Name: folder.Name,
@@ -209,7 +208,7 @@ func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) {
209208
})
210209
}
211210
for _, file := range resp.FileListAO.FileList {
212-
lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05", file.LastOpTime, loc)
211+
lastOpTime := utils.MustParseCNTime(file.LastOpTime)
213212
res = append(res, &model.ObjThumb{
214213
Object: model.Object{
215214
ID: strconv.FormatInt(file.Id, 10),

pkg/utils/time.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package utils
2+
3+
import "time"
4+
5+
func MustParseCNTime(str string) time.Time {
6+
lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05 -07", str+" +08", time.Local)
7+
return lastOpTime
8+
}

0 commit comments

Comments
 (0)