mirror of
https://gitee.com/dromara/carbon.git
synced 2024-11-29 18:57:37 +08:00
更新文档
This commit is contained in:
parent
59860f404d
commit
06fb6355b5
22
README.cn.md
22
README.cn.md
@ -1274,6 +1274,10 @@ carbon.Parse("2020-03-21 21:00:00").Lunar().IsTwelfthDoubleHour() // true
|
||||
|
||||
###### 场景一: 所有时间字段有相同的格式
|
||||
```go
|
||||
carbon.SetDefault(carbon.Default{
|
||||
Layout: carbon.RFC3339Layout,
|
||||
})
|
||||
|
||||
type Person struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age"`
|
||||
@ -1289,10 +1293,6 @@ type Person struct {
|
||||
Field8 Carbon `json:"field8"`
|
||||
}
|
||||
|
||||
carbon.SetDefault(carbon.Default{
|
||||
Layout: carbon.RFC3339Layout,
|
||||
})
|
||||
|
||||
now := carbon.Parse("2020-08-05 13:14:15", carbon.PRC)
|
||||
person := Person {
|
||||
Name: "gouguoyin",
|
||||
@ -1468,13 +1468,13 @@ fmt.Printf("%d", person.Field8) // 1596604455999999999
|
||||
|
||||
目前支持的方法有
|
||||
|
||||
* `Constellation()`:获取星座
|
||||
* `Season()`:获取季节
|
||||
* `DiffForHumans()`:获取对人类友好的可读格式时间差
|
||||
* `ToMonthString()`:输出完整月份字符串
|
||||
* `ToShortMonthString()`:输出缩写月份字符串
|
||||
* `ToWeekString()`:输出完整星期字符串
|
||||
* `ToShortWeekString()`:输出缩写星期字符串
|
||||
* `Constellation()`:获取星座,如 `白羊座`
|
||||
* `Season()`:获取季节,如 `夏季`
|
||||
* `DiffForHumans()`:获取对人类友好的可读格式时间差,如 `一小时前`
|
||||
* `ToMonthString()`:输出完整月份字符串,如 `一月`
|
||||
* `ToShortMonthString()`:输出缩写月份字符串,如 `1月`
|
||||
* `ToWeekString()`:输出完整星期字符串,如 `星期一`
|
||||
* `ToShortWeekString()`:输出缩写星期字符串,如 `周一`
|
||||
|
||||
###### 设置区域
|
||||
|
||||
|
22
README.jp.md
22
README.jp.md
@ -1274,6 +1274,10 @@ carbon.Parse("2020-03-21 21:00:00").Lunar().IsTwelfthDoubleHour() // true
|
||||
|
||||
###### シナリオ 1: すべての時刻フィールドが同じ形式である
|
||||
```go
|
||||
carbon.SetDefault(carbon.Default{
|
||||
Layout: carbon.RFC3339Layout,
|
||||
})
|
||||
|
||||
type Person struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age"`
|
||||
@ -1289,10 +1293,6 @@ type Person struct {
|
||||
Field8 Carbon `json:"field8"`
|
||||
}
|
||||
|
||||
carbon.SetDefault(carbon.Default{
|
||||
Layout: carbon.RFC3339Layout,
|
||||
})
|
||||
|
||||
now := carbon.Parse("2020-08-05 13:14:15", carbon.PRC)
|
||||
person := Person {
|
||||
Name: "gouguoyin",
|
||||
@ -1468,13 +1468,13 @@ fmt.Printf("%d", person.Field8) // 1596604455999999999
|
||||
|
||||
現在サポートされている方法
|
||||
|
||||
* `Constellation()`:星座を取得
|
||||
* `Season()`:シーズンを取得
|
||||
* `DiffForHumans()`:人間に優しい読み取り可能なフォーマットの時間差を取得します
|
||||
* `ToMonthString()`:月文字列を出力
|
||||
* `ToShortMonthString()`:略語月文字列を出力
|
||||
* `ToWeekString()`:週文字列を出力
|
||||
* `ToShortWeekString()`:略語週文字列を出力
|
||||
* `Constellation()`:星座を取得,例えば `おひつじ座`
|
||||
* `Season()`:シーズンを取得,例えば `春`
|
||||
* `DiffForHumans()`:人間に優しい読み取り可能なフォーマットの時間差を取得します,例えば `一時間前`
|
||||
* `ToMonthString()`:月文字列を出力,例えば `いちがつ`
|
||||
* `ToShortMonthString()`:略語月文字列を出力,例えば `1がつ`
|
||||
* `ToWeekString()`:週文字列を出力,例えば `日曜日`
|
||||
* `ToShortWeekString()`:略語週文字列を出力,例えば `日`
|
||||
|
||||
###### エリアの設定
|
||||
|
||||
|
22
README.md
22
README.md
@ -1269,6 +1269,10 @@ carbon.Parse("2020-03-21 21:00:00").Lunar().IsTwelfthDoubleHour() // true
|
||||
|
||||
###### Scene one: all time fields have the same format
|
||||
```go
|
||||
carbon.SetDefault(carbon.Default{
|
||||
Layout: carbon.RFC3339Layout,
|
||||
})
|
||||
|
||||
type Person struct {
|
||||
Name string `json:"name"`
|
||||
Age int `json:"age"`
|
||||
@ -1284,10 +1288,6 @@ type Person struct {
|
||||
Field8 Carbon `json:"field8"`
|
||||
}
|
||||
|
||||
carbon.SetDefault(carbon.Default{
|
||||
Layout: carbon.RFC3339Layout,
|
||||
})
|
||||
|
||||
now := carbon.Parse("2020-08-05 13:14:15", carbon.PRC)
|
||||
person := Person {
|
||||
Name: "gouguoyin",
|
||||
@ -1469,13 +1469,13 @@ The following languages are supported
|
||||
|
||||
The following methods are supported
|
||||
|
||||
* `Constellation()`:get constellation name
|
||||
* `Season()`:get season name
|
||||
* `DiffForHumans()`:get the difference with human-readable format
|
||||
* `ToMonthString()`:output month format string
|
||||
* `ToShortMonthString()`:output short month format string
|
||||
* `ToWeekString()`:output week format string
|
||||
* `ToShortWeekString()`:output short week format string
|
||||
* `Constellation()`:get constellation name, like `Aries`
|
||||
* `Season()`:get season name, like `Spring`
|
||||
* `DiffForHumans()`:get the difference with human-readable format, like `1 year from now`
|
||||
* `ToMonthString()`:output month format string, like `January`
|
||||
* `ToShortMonthString()`:output short month format string, like `Jan`
|
||||
* `ToWeekString()`:output week format string, like `Sunday`
|
||||
* `ToShortWeekString()`:output short week format string, like `Sun`
|
||||
|
||||
###### Set locale
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user