1
0
mirror of https://github.com/gogf/gf.git synced 2025-04-05 11:18:50 +08:00

os/gtime: fixed gtime ci fail (#3596)

This commit is contained in:
海亮 2024-05-22 20:45:39 +08:00 committed by GitHub
parent 1b23bf495a
commit 21c83670d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 9 deletions

View File

@ -190,6 +190,7 @@ jobs:
steps:
# TODO: szenius/set-timezone update to node16
# sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- name: Setup Timezone
uses: szenius/set-timezone@v1.1
with:

View File

@ -111,21 +111,14 @@ func Test_StrToTime(t *testing.T) {
"02.jan.2006 15:04:05",
"02.jan.2006:15:04:05",
}
// Save the previous time zone
local := *time.Local
defer func() {
*time.Local = local
}()
time.Local = time.FixedZone("Asia/Shanghai", 8*3600)
for i, item := range testDateTimes {
for _, item := range testDateTimes {
timeTemp, err := gtime.StrToTime(item)
t.AssertNil(err)
t.Log(i)
t.Assert(timeTemp.Time.Local().Format("2006-01-02 15:04:05"), "2006-01-02 15:04:05")
}
// Correct date string,.
// Correct date string.
var testDates = []string{
"2006.01.02",
"2006.01.02 00:00",