Repository navigation
Expand file tree
/
Copy pathextremum_example_test.go
More file actions
97 lines (75 loc) · 1.95 KB
/
Copy pathextremum_example_test.go
File metadata and controls
97 lines (75 loc) · 1.95 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package carbon_test
import (
"fmt"
"github.com/dromara/carbon/v2"
)
func ExampleZeroValue() {
fmt.Println(carbon.ZeroValue().ToString())
// Output:
// 0001-01-01 00:00:00 +0000 UTC
}
func ExampleEpochValue() {
fmt.Println(carbon.EpochValue().ToString())
// Output:
// 1970-01-01 00:00:00 +0000 UTC
}
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:
// 0001-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() {
c1 := carbon.Parse("2020-08-01")
c2 := carbon.Parse("2020-08-05")
c3 := carbon.Parse("2020-08-06")
fmt.Println(carbon.Max(c1, c2, c3).ToString())
// Output:
// 2020-08-06 00:00:00 +0000 UTC
}
func ExampleMin() {
c1 := carbon.Parse("2020-08-01")
c2 := carbon.Parse("2020-08-05")
c3 := carbon.Parse("2020-08-06")
fmt.Println(carbon.Min(c1, c2, c3).ToString())
// Output:
// 2020-08-01 00:00:00 +0000 UTC
}
func ExampleCarbon_Closest() {
c1 := carbon.Parse("2020-08-01")
c2 := carbon.Parse("2020-08-05")
c3 := carbon.Parse("2020-08-06")
fmt.Println(c1.Closest(c2, c3).ToString())
fmt.Println(c2.Closest(c1, c3).ToString())
fmt.Println(c3.Closest(c2, c1).ToString())
// Output:
// 2020-08-05 00:00:00 +0000 UTC
// 2020-08-06 00:00:00 +0000 UTC
// 2020-08-05 00:00:00 +0000 UTC
}
func ExampleCarbon_Farthest() {
c1 := carbon.Parse("2020-08-01")
c2 := carbon.Parse("2020-08-05")
c3 := carbon.Parse("2020-08-06")
fmt.Println(c1.Farthest(c2, c3).ToString())
fmt.Println(c2.Farthest(c1, c3).ToString())
fmt.Println(c3.Farthest(c1, c2).ToString())
// Output:
// 2020-08-06 00:00:00 +0000 UTC
// 2020-08-01 00:00:00 +0000 UTC
// 2020-08-01 00:00:00 +0000 UTC
}