Skip to content

Commit

Permalink
Fix JST offset
Browse files Browse the repository at this point in the history
  • Loading branch information
osamingo committed Mar 19, 2022
1 parent c1ac7d0 commit 82431c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var (
// nolint: gochecknoglobals
nullLiteral = []byte("null")
// nolint: gochecknoglobals, gomnd
jst = time.FixedZone("Asia/Tokyo", int(9*time.Hour))
jst = time.FixedZone("Asia/Tokyo", 9*60*60)

_ json.Unmarshaler = (*Version)(nil)
_ json.Unmarshaler = (*NullString)(nil)
Expand Down
4 changes: 2 additions & 2 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestHoliday_UnmarshalJSON(t *testing.T) {
wantTime time.Time
wantError bool
}{
"Normal case": {give: `{"title":"元日","date":"2022-01-01","day_of_week":6,"day_of_week_text":"saturday"}`, wantTitle: "元日", wantTime: time.Date(2022, 1, 1, 0, 0, 0, 0, time.FixedZone("Asia/Tokyo", int(9*time.Hour))), wantError: false},
"Normal case": {give: `{"title":"元日","date":"2022-01-01","day_of_week":6,"day_of_week_text":"saturday"}`, wantTitle: "元日", wantTime: time.Date(2022, 1, 1, 0, 0, 0, 0, time.FixedZone("Asia/Tokyo", 9*60*60)), wantError: false},
"Unexpected JSON value": {give: `{"title":2,"date":"2022-01-01","day_of_week":6,"day_of_week_text":"saturday"}`, wantTitle: "", wantTime: time.Time{}, wantError: true},
"Unexpected date format": {give: `{"title":"元日","date":"2022/01/01","day_of_week":6,"day_of_week_text":"saturday"}`, wantTitle: "", wantTime: time.Time{}, wantError: true},
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestHoliday_MarshalJSON(t *testing.T) {
want []byte
wantError bool
}{
"Normal case": {give: &kenall.Holiday{Title: "元日", Time: time.Date(2022, 1, 1, 0, 0, 0, 0, time.FixedZone("Asia/Tokyo", int(9*time.Hour)))}, want: []byte(`{"title":"元日","date":"2022-01-01","day_of_week":6,"day_of_week_text":"saturday"}`), wantError: false},
"Normal case": {give: &kenall.Holiday{Title: "元日", Time: time.Date(2022, 1, 1, 0, 0, 0, 0, time.FixedZone("Asia/Tokyo", 9*60*60))}, want: []byte(`{"title":"元日","date":"2022-01-01","day_of_week":6,"day_of_week_text":"saturday"}`), wantError: false},
"Empty case": {give: &kenall.Holiday{}, want: []byte(`{"title":"","date":"0001-01-01","day_of_week":1,"day_of_week_text":"monday"}`), wantError: false},
}

Expand Down

0 comments on commit 82431c9

Please sign in to comment.