Skip to content

Commit

Permalink
Update content
Browse files Browse the repository at this point in the history
  • Loading branch information
kuafuRace committed Jan 9, 2024
1 parent 8b7ce65 commit 4c25b06
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 40 deletions.
26 changes: 14 additions & 12 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ import "gitee.com/golang-module/carbon"

> 假设当前时间为 2020-08-05 13:14:15.999999999 +0800 CST
##### 设置全局默认值
##### 设置默认值(全局生效)

```go
carbon.SetDefault(carbon.Default{
Layout: carbon.RFC3339Layout,
Timezone: carbon.PRC,
WeekStartsAt: carbon.Sunday,
Locale: "zh-CN",
})
```

> 如果没有设置,默认布局模板是 `2006-01-02 15:04:05`, 默认时区是 `Local`, 默认语言是 `en`
> 如果没有设置,默认布局模板是 `2006-01-02 15:04:05`, 默认时区是 `Local`, 默认一周开始日期是 `Sunday(周日)`, 默认语言是 `en`
##### 昨天、今天、明天

Expand Down Expand Up @@ -555,20 +556,21 @@ carbon.Parse("2022-08-05 13:14:15").DiffForHumans(carbon.Now()) // 2 years after
##### 时间极值

```go
c := carbon.Parse("2023-04-01")
c0 := carbon.Parse("xxx")
c0 := carbon.Parse("2023-04-01")
c1 := carbon.Parse("2023-03-28")
c2 := carbon.Parse("2023-04-16")

// 返回最近的 Carbon 实例
c.Closest(c0, c1) // c1
c.Closest(c0, c2) // c2
c.Closest(c1, c2) // c1

c0.Closest(c1, c2) // c1
// 返回最远的 Carbon 实例
c.Farthest(c0, c1) // c1
c.Farthest(c0, c2) // c2
c.Farthest(c1, c2) // c2
c0.Farthest(c1, c2) // c2

yesterday := carbon.Yesterday()
today := carbon.Now()
tomorrow := carbon.Tomorrow()
// 返回最大的 Carbon 实例
carbon.Max(yesterday, today, tomorrow) // tomorrow
// 返回最小的 Carbon 实例
carbon.Min(yesterday, today, tomorrow) // yesterday
```

##### 时间判断
Expand Down
26 changes: 14 additions & 12 deletions README.jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@ import "gitee.com/golang-module/carbon"

> 現在時刻が 2020-08-05 13:14:15.999999999 +0800 CST であると仮定します。
##### グローバルデフォルトを設定する
##### デフォルト値の設定 (グローバルに有効)

```go
carbon.SetDefault(carbon.Default{
Layout: carbon.RFC3339Layout,
Timezone: carbon.PRC,
WeekStartsAt: carbon.Sunday,
Locale: "jp",
})
```

> 設定されていない場合デフォルトのレイアウト テンプレートは `2006-01-02 15:04:05`、デフォルトのタイム ゾーンは `Local`デフォルトの言語は `en` になります
> 設定されていない場合デフォルトのレイアウト テンプレートは `2006-01-02 15:04:05`,デフォルトのタイムゾーンは `Local`,デフォルトの週の開始日は `日曜日`デフォルトの言語は `en` です
##### 昨日、今日、明日

Expand Down Expand Up @@ -555,20 +556,21 @@ carbon.Parse("2022-08-05 13:14:15").DiffForHumans(carbon.Now()) // 2 years after
##### 时间极值

```go
c := carbon.Parse("2023-04-01")
c0 := carbon.Parse("xxx")
c0 := carbon.Parse("2023-04-01")
c1 := carbon.Parse("2023-03-28")
c2 := carbon.Parse("2023-04-16")

// 最近のCarbonインスタンスを返す
c.Closest(c0, c1) // c1
c.Closest(c0, c2) // c2
c.Closest(c1, c2) // c1

c0.Closest(c1, c2) // c1
// 最も遠いCarbonインスタンスを返す
c.Farthest(c0, c1) // c1
c.Farthest(c0, c2) // c2
c.Farthest(c1, c2) // c2
c0.Farthest(c1, c2) // c2

yesterday := carbon.Yesterday()
today := carbon.Now()
tomorrow := carbon.Tomorrow()
// 最大の Carbon インスタンスを返します
carbon.Max(yesterday, today, tomorrow) // tomorrow
// 最小の Carbon インスタンスを返します
carbon.Min(yesterday, today, tomorrow) // yesterday
```

##### 时间比較
Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ English | [简体中文](README.cn.md) | [日本語](README.jp.md)

#### Introduction

A simple, semantic and developer-friendly golang package for datetime, has been included
A simple, semantic and developer-friendly golang package for time, has been included
by [awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go")

[github.com/golang-module/carbon](https://github.com/golang-module/carbon "github.com/golang-module/carbon")
Expand Down Expand Up @@ -55,17 +55,18 @@ import "gitee.com/golang-module/carbon"

> Assuming the current time is 2020-08-05 13:14:15.999999999 +0800 CST
##### Set global default
##### Set default values (globally effective)

```go
carbon.SetDefault(carbon.Default{
Layout: carbon.RFC3339Layout,
Timezone: carbon.PRC,
Layout: carbon.DateTimeLayout,
Timezone: carbon.Local,
WeekStartsAt: carbon.Sunday,
Locale: "en",
})
```

> If not set, the default layout is `2006-01-02 15:04:05`, the default timezone is `Local`, and the default language locale is `en`
> If not set, the default layout is `2006-01-02 15:04:05`, the default timezone is `Local`, the default week start date is `Sunday` and the default language locale is `en`
##### Yesterday, today and tomorrow

Expand Down Expand Up @@ -552,20 +553,21 @@ carbon.Parse("2022-08-05 13:14:15").DiffForHumans(carbon.Now()) // 2 years after
##### Extremum

```go
c := carbon.Parse("2023-04-01")
c0 := carbon.Parse("xxx")
c0 := carbon.Parse("2023-04-01")
c1 := carbon.Parse("2023-03-28")
c2 := carbon.Parse("2023-04-16")

// Return the closest Carbon instance
c.Closest(c0, c1) // c1
c.Closest(c0, c2) // c2
c.Closest(c1, c2) // c1

c0.Closest(c1, c2) // c1
// Return the farthest Carbon instance
c.Farthest(c0, c1) // c1
c.Farthest(c0, c2) // c2
c.Farthest(c1, c2) // c2
c0.Farthest(c1, c2) // c2

yesterday := carbon.Yesterday()
today := carbon.Now()
tomorrow := carbon.Tomorrow()
// Return the maximum Carbon instance
carbon.Max(yesterday, today, tomorrow) // tomorrow
// Return the minimum Carbon instance
carbon.Min(yesterday, today, tomorrow) // yesterday
```

##### Comparison
Expand Down Expand Up @@ -1471,7 +1473,7 @@ The following methods are supported

* `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`
* `DiffForHumans()`:get the difference with human-readable format string, 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`
Expand Down

0 comments on commit 4c25b06

Please sign in to comment.