From fbaebc020f6b1cbf443ba99634b3367882c9f683 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Thu, 8 Sep 2022 20:03:07 +0800 Subject: [PATCH] fix(189pc): wrong time if location incorrect (close #1562) --- drivers/189pc/help.go | 3 ++- pkg/utils/file.go | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/189pc/help.go b/drivers/189pc/help.go index abeceb3e..52259397 100644 --- a/drivers/189pc/help.go +++ b/drivers/189pc/help.go @@ -78,7 +78,8 @@ func timestamp() int64 { } func MustParseTime(str string) *time.Time { - lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05", str, time.Local) + loc, _ := time.LoadLocation("Asia/Shanghai") + lastOpTime, _ := time.ParseInLocation("2006-01-02 15:04:05", str, loc) return &lastOpTime } diff --git a/pkg/utils/file.go b/pkg/utils/file.go index d053173e..7f9372b8 100644 --- a/pkg/utils/file.go +++ b/pkg/utils/file.go @@ -2,7 +2,6 @@ package utils import ( "io" - "io/ioutil" "os" "path/filepath" @@ -35,7 +34,7 @@ func CreateNestedFile(path string) (*os.File, error) { // CreateTempFile create temp file from io.ReadCloser, and seek to 0 func CreateTempFile(r io.ReadCloser) (*os.File, error) { - f, err := ioutil.TempFile(conf.Conf.TempDir, "file-*") + f, err := os.CreateTemp(conf.Conf.TempDir, "file-*") if err != nil { return nil, err }