forked from dromara/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextremum_example_test.go
55 lines (45 loc) · 1.23 KB
/
extremum_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package carbon_test
import (
"fmt"
"github.com/dromara/carbon/v2"
)
func ExampleMaxValue() {
fmt.Println(carbon.MaxValue().ToString())
// Output:
// 9999-12-31 23:59:59.999999999 +0000 UTC
}
func ExampleMinValue() {
fmt.Println(carbon.MinValue().ToString())
// Output:
// -9998-01-01 00:00:00 +0000 UTC
}
func ExampleMaxDuration() {
fmt.Println(carbon.MaxDuration().Seconds())
// Output:
// 9.223372036854776e+09
}
func ExampleMinDuration() {
fmt.Println(carbon.MinDuration().Seconds())
// Output:
// -9.223372036854776e+09
}
func ExampleMax() {
fmt.Println(carbon.Max(carbon.Parse("2020-08-06"), carbon.Parse("2021-08-05")).ToString())
// Output:
// 2021-08-05 00:00:00 +0000 UTC
}
func ExampleMin() {
fmt.Println(carbon.Min(carbon.Parse("2020-08-06"), carbon.Parse("2021-08-05")).ToString())
// Output:
// 2020-08-06 00:00:00 +0000 UTC
}
func ExampleCarbon_Closest() {
fmt.Println(carbon.Parse("2020-08-05").Closest(carbon.Parse("2020-08-06"), carbon.Parse("2021-08-05")).ToString())
// Output:
// 2020-08-06 00:00:00 +0000 UTC
}
func ExampleCarbon_Farthest() {
fmt.Println(carbon.Parse("2020-08-05").Farthest(carbon.Parse("2020-08-06"), carbon.Parse("2021-08-05")).ToString())
// Output:
// 2021-08-05 00:00:00 +0000 UTC
}