Skip to content

Commit

Permalink
Update content
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Sep 11, 2023
1 parent 6b8b501 commit bfbf3b6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
28 changes: 24 additions & 4 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -1287,15 +1287,35 @@ person := Person {
CreatedAt4: carbon.Now().ToTimestampNanoStruct(),
}

person.Birthday1.String() // 2002-08-05 13:14:15
person.Birthday2.String() // 2002-08-05 13:14:15.999
person.Birthday3.String() // 2002-08-05 13:14:15.999999
person.Birthday4.String() // 2002-08-05 13:14:15.999999999

person.GraduatedAt1.String() // 2020-08-05
person.GraduatedAt2.String() // 2020-08-05.999
person.GraduatedAt3.String() // 2020-08-05.999999
person.GraduatedAt4.String() // 2020-08-05.999999999

person.CreatedAt1.String() // "1691212455"
person.CreatedAt2.String() // "1722834855999"
person.CreatedAt3.String() // "1754370855999999"
person.CreatedAt4.String() // "1754370855999999999"

person.CreatedAt1.Int64() // 1691212455
person.CreatedAt2.Int64() // 1722834855999
person.CreatedAt3.Int64() // 1754370855999999
person.CreatedAt4.Int64() // 1754370855999999999

```

###### JSON 编码

```go
data, err := json.Marshal(&person)
if err != nil {
// 错误处理
log.Fatal(err)
// 错误处理
log.Fatal(err)
}
fmt.Printf("%s", data)
// 输出
Expand Down Expand Up @@ -1339,8 +1359,8 @@ str := `{
person := new(Person)
err := json.Unmarshal([]byte(str), &person)
if err != nil {
// 错误处理
log.Fatal(err)
// 错误处理
log.Fatal(err)
}
fmt.Printf("%+v", *person)
// 输出
Expand Down
20 changes: 20 additions & 0 deletions README.jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,26 @@ person := Person {
CreatedAt3: carbon.Now().ToTimestampMicroStruct(),
CreatedAt4: carbon.Now().ToTimestampNanoStruct(),
}

person.Birthday1.String() // 2002-08-05 13:14:15
person.Birthday2.String() // 2002-08-05 13:14:15.999
person.Birthday3.String() // 2002-08-05 13:14:15.999999
person.Birthday4.String() // 2002-08-05 13:14:15.999999999

person.GraduatedAt1.String() // 2020-08-05
person.GraduatedAt2.String() // 2020-08-05.999
person.GraduatedAt3.String() // 2020-08-05.999999
person.GraduatedAt4.String() // 2020-08-05.999999999

person.CreatedAt1.String() // "1691212455"
person.CreatedAt2.String() // "1722834855999"
person.CreatedAt3.String() // "1754370855999999"
person.CreatedAt4.String() // "1754370855999999999"

person.CreatedAt1.Int64() // 1691212455
person.CreatedAt2.Int64() // 1722834855999
person.CreatedAt3.Int64() // 1754370855999999
person.CreatedAt4.Int64() // 1754370855999999999
```

###### JSON コーディング
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,26 @@ person := Person {
CreatedAt3: carbon.Now().ToTimestampMicroStruct(),
CreatedAt4: carbon.Now().ToTimestampNanoStruct(),
}

person.Birthday1.String() // 2002-08-05 13:14:15
person.Birthday2.String() // 2002-08-05 13:14:15.999
person.Birthday3.String() // 2002-08-05 13:14:15.999999
person.Birthday4.String() // 2002-08-05 13:14:15.999999999

person.GraduatedAt1.String() // 2020-08-05
person.GraduatedAt2.String() // 2020-08-05.999
person.GraduatedAt3.String() // 2020-08-05.999999
person.GraduatedAt4.String() // 2020-08-05.999999999

person.CreatedAt1.String() // "1691212455"
person.CreatedAt2.String() // "1722834855999"
person.CreatedAt3.String() // "1754370855999999"
person.CreatedAt4.String() // "1754370855999999999"

person.CreatedAt1.Int64() // 1691212455
person.CreatedAt2.Int64() // 1722834855999
person.CreatedAt3.Int64() // 1754370855999999
person.CreatedAt4.Int64() // 1754370855999999999
```

###### JSON encode
Expand Down

0 comments on commit bfbf3b6

Please sign in to comment.