2 Star 0 Fork 70

golang-package/carbon

forked from dromara/carbon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
extremum_example_test.go 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
package carbon_test
import (
"fmt"
"gitee.com/golang-package/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
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/golang-package/carbon.git
git@gitee.com:golang-package/carbon.git
golang-package
carbon
carbon
master

搜索帮助