Skip to content

Commit

Permalink
Add description about Closest and Farthest methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Nov 7, 2023
1 parent 0dd0acf commit e04fb0e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ carbon.CreateFromStdTime(time.Now())
carbon.Now().ToStdTime()
```

##### 最近和最远

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

// 返回最近的 Carbon 实例
c.Closest(c1, c2).ToDateString() // 2023-03-28
// 返回最远的 Carbon 实例
c.Farthest(c1, c2).ToDateString() // 2023-04-16
```

##### 开始时间、结束时间

```go
Expand Down
13 changes: 13 additions & 0 deletions README.jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ carbon.CreateFromStdTime(time.Now())
carbon.Now().ToStdTime()
```

##### 最近と最も遠い

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

// 最近のCarbonインスタンスを返す
c.Closest(c1, c2).ToDateString() // 2023-03-28
// 最も遠いCarbonインスタンスを返す
c.Farthest(c1, c2).ToDateString() // 2023-04-16
```

##### 始まりと終わり

```go
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ carbon.CreateFromStdTime(time.Now())
carbon.Now().ToStdTime()
```

##### Closest and farthest

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

// Return the closest Carbon instance
c.Closest(c1, c2).ToDateString() // 2023-03-28
// Return the farthest Carbon instance
c.Farthest(c1, c2).ToDateString() // 2023-04-16
```

##### Start and end

```go
Expand Down

0 comments on commit e04fb0e

Please sign in to comment.