修复进行 UnmarshalJSON 时时区错误的 bug

This commit is contained in:
gouguoyin 2024-11-25 01:40:46 +08:00
parent e69a5e300a
commit d45e1b5266
3 changed files with 11 additions and 11 deletions

View File

@ -9,12 +9,12 @@ import (
func TestCarbon_SetDefault(t *testing.T) {
SetDefault(Default{
Layout: DateTimeLayout,
Timezone: Local,
Timezone: PRC,
Locale: "en",
WeekStartsAt: Sunday,
})
assert.Equal(t, DateTimeLayout, defaultLayout)
assert.Equal(t, Local, defaultTimezone)
assert.Equal(t, PRC, defaultTimezone)
assert.Equal(t, "en", defaultLocale)
assert.Equal(t, "Sunday", defaultWeekStartsAt)
}

View File

@ -424,6 +424,6 @@ func TestCarbon_Issue243(t *testing.T) {
if err != nil {
log.Fatal(err)
}
assert.Equal(t, "Local", project.StartDate.Location())
assert.Equal(t, "Local", project.EndDate.Location())
assert.Equal(t, "PRC", project.StartDate.Location())
assert.Equal(t, "PRC", project.EndDate.Location())
}

View File

@ -54,18 +54,18 @@ func TestCarbon_GoString(t *testing.T) {
},
{
name: "case2",
actual: Parse("0000-01-01 13:14:15").GoString(),
want: "time.Date(0, time.January, 1, 13, 14, 15, 0, time.Local)",
actual: Parse("0000-01-01 13:14:15", UTC).GoString(),
want: "time.Date(0, time.January, 1, 13, 14, 15, 0, time.UTC)",
},
{
name: "case3",
actual: Parse("0001-01-01 13:14:15").GoString(),
want: "time.Date(1, time.January, 1, 13, 14, 15, 0, time.Local)",
actual: Parse("0001-01-01 13:14:15", UTC).GoString(),
want: "time.Date(1, time.January, 1, 13, 14, 15, 0, time.UTC)",
},
{
name: "case4",
actual: Parse("2020-08-05 13:14:15").GoString(),
want: "time.Date(2020, time.August, 5, 13, 14, 15, 0, time.Local)",
actual: Parse("2020-08-05 13:14:15", UTC).GoString(),
want: "time.Date(2020, time.August, 5, 13, 14, 15, 0, time.UTC)",
},
}
@ -2652,7 +2652,7 @@ func TestCarbon_ToStdTime(t *testing.T) {
assert.Equal(t, expected, actual)
}
// https://github.com/golang-module/carbon/issues/200
// https://github.com/dromara/carbon/issues/200
func TestCarbon_Issue200(t *testing.T) {
tests1 := []struct {
name string