Skip to content

Commit 75934b1

Browse files
committed
tests: change tests base time to local
1 parent 7efa282 commit 75934b1

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

dateutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func DateTime(target interface{}) (time.Time, error) {
292292
return time.Time{}, fmt.Errorf("wrong datatime %v", target)
293293
}
294294
location, _ := time.LoadLocation("Local")
295-
return time.Unix(timestamp, 0).UTC().In(location), nil
295+
return time.Unix(timestamp, 0).In(location), nil
296296
}
297297

298298
// get any of the argument fields in the target format result

dateutil_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var (
2828
)
2929

3030
func makeTestTime() time.Time {
31-
return time.Date(2021, time.September, 5, 18, 7, 6, 12345678, time.UTC)
31+
return time.Date(2021, time.September, 5, 18, 7, 6, 12345678, time.Local)
3232
}
3333

3434
func isSameDate(date *time.Time, mode EnumDate, args ...bool) bool {
@@ -247,6 +247,7 @@ func TestNumberDate(t *testing.T) {
247247
// 2021-09-05 18:07:06 since 1970
248248
var timestamp int = 1630836426
249249
if date, err := DateTime(timestamp); err == nil {
250+
assert.Equal(t, date.Hour(), 18)
250251
assert.True(t, isSameDate(&date, YMDHis))
251252
} else {
252253
assert.Fail(t, "DateTime int fail")

0 commit comments

Comments
 (0)