1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: add doc for BetweenSeconds

This commit is contained in:
dudaodong
2023-05-30 17:47:16 +08:00
parent 6fbaf2b005
commit 388171e739
2 changed files with 78 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ import (
- [ToFormatForTpl](#ToFormatForTpl)
- [ToIso8601](#ToIso8601)
- [IsLeapYear](#IsLeapYear)
- [BetweenSeconds](#BetweenSeconds)
<div STYLE="page-break-after: always;"></div>
@@ -1136,3 +1137,41 @@ func main() {
// false
}
```
### <span id="BetweenSeconds">BetweenSeconds</span>
<p>Return the number of seconds between two times.</p>
<b>Signature:</b>
```go
func BetweenSeconds(t1 time.Time, t2 time.Time) int64
```
<b>Example:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/datetime"
)
func main() {
today := time.Now()
tomorrow := AddDay(today, 1)
yesterday := AddDay(today, -1)
result1 := datetime.BetweenSeconds(today, tomorrow)
result2 := datetime.BetweenSeconds(today, yesterday)
fmt.Println(result1)
fmt.Println(result2)
// Output:
// 86400
// -86400
}
```

View File

@@ -54,6 +54,8 @@ import (
- [ToFormatForTpl](#ToFormatForTpl)
- [ToIso8601](#ToIso8601)
- [IsLeapYear](#IsLeapYear)
- [BetweenSeconds](#BetweenSeconds)
<div STYLE="page-break-after: always;"></div>
@@ -1135,3 +1137,40 @@ func main() {
// false
}
```
### <span id="BetweenSeconds">BetweenSeconds</span>
<p>返回两个时间的间隔秒数。</p>
<b>函数签名:</b>
```go
func BetweenSeconds(t1 time.Time, t2 time.Time) int64
```
<b>示例:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/datetime"
)
func main() {
today := time.Now()
tomorrow := AddDay(today, 1)
yesterday := AddDay(today, -1)
result1 := datetime.BetweenSeconds(today, tomorrow)
result2 := datetime.BetweenSeconds(today, yesterday)
fmt.Println(result1)
fmt.Println(result2)
// Output:
// 86400
// -86400
}
```