Skip to content

Commit

Permalink
Add ToXXXStruct series methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Sep 11, 2023
1 parent 34cdfff commit 94228a8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ type Person struct {
var person Person

func TestCarbon_MarshalJSON(t *testing.T) {
testNow := SetTestNow(Parse("2020-08-05 13:14:15.999999999"))
testNow := SetTestNow(Parse("2020-08-05 13:14:15.999999999", PRC))
person = Person{
Name: "gouguoyin",
Age: 18,
Birthday1: testNow.Now().SubYears(18).ToDateTimeStruct(),
Birthday2: testNow.Now().SubYears(18).ToDateTimeMilliStruct(),
Birthday3: testNow.Now().SubYears(18).ToDateTimeMicroStruct(),
Birthday4: testNow.Now().SubYears(18).ToDateTimeNanoStruct(),
GraduatedAt1: Parse("2020-08-05 13:14:15", UTC).ToDateStruct(),
GraduatedAt2: Parse("2020-08-05 13:14:15.999", UTC).ToDateMilliStruct(),
GraduatedAt3: Parse("2020-08-05 13:14:15.999999", UTC).ToDateMicroStruct(),
GraduatedAt4: Parse("2020-08-05 13:14:15.999999999", UTC).ToDateNanoStruct(),
CreatedAt1: Parse("2023-08-05 13:14:15", UTC).ToTimestampStruct(),
CreatedAt2: Parse("2024-08-05 13:14:15.999", UTC).ToTimestampMilliStruct(),
CreatedAt3: Parse("2025-08-05 13:14:15.999999", UTC).ToTimestampMicroStruct(),
CreatedAt4: Parse("2025-08-05 13:14:15.999999999", UTC).ToTimestampNanoStruct(),
GraduatedAt1: Parse("2020-08-05 13:14:15", PRC).ToDateStruct(),
GraduatedAt2: Parse("2020-08-05 13:14:15.999", PRC).ToDateMilliStruct(),
GraduatedAt3: Parse("2020-08-05 13:14:15.999999", PRC).ToDateMicroStruct(),
GraduatedAt4: Parse("2020-08-05 13:14:15.999999999", PRC).ToDateNanoStruct(),
CreatedAt1: Parse("2023-08-05 13:14:15", PRC).ToTimestampStruct(),
CreatedAt2: Parse("2024-08-05 13:14:15.999", PRC).ToTimestampMilliStruct(),
CreatedAt3: Parse("2025-08-05 13:14:15.999999", PRC).ToTimestampMicroStruct(),
CreatedAt4: Parse("2025-08-05 13:14:15.999999999", PRC).ToTimestampNanoStruct(),
}
data, err := json.Marshal(&person)
assert.Nil(t, err)
Expand Down

0 comments on commit 94228a8

Please sign in to comment.