diff --git a/go.mod b/go.mod
index a6fe4321..f761c11f 100644
--- a/go.mod
+++ b/go.mod
@@ -9,13 +9,13 @@ require (
github.com/aws/aws-sdk-go-v2/credentials v1.17.48
github.com/aws/aws-sdk-go-v2/service/route53 v1.46.4
github.com/crazy-max/gonfig v0.7.1
+ github.com/dromara/carbon/v2 v2.5.2
github.com/go-playground/validator/v10 v10.23.0
- github.com/golang-module/carbon/v2 v2.3.10
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/pkg/errors v0.9.1
github.com/robfig/cron/v3 v3.0.1
github.com/rs/zerolog v1.33.0
- github.com/stretchr/testify v1.9.0
+ github.com/stretchr/testify v1.10.0
golang.org/x/sys v0.28.0
)
diff --git a/go.sum b/go.sum
index ae910040..ee342c7a 100644
--- a/go.sum
+++ b/go.sum
@@ -40,6 +40,8 @@ github.com/crazy-max/gonfig v0.7.1/go.mod h1:csPFrGh/m0nIamCJbah1ZN2/+5s510nQQ7s
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dromara/carbon/v2 v2.5.2 h1:GquNyA9Imda+LwS9FIzHhKg+foU2QPstH+S3idBRjKg=
+github.com/dromara/carbon/v2 v2.5.2/go.mod h1:zyPlND2o27sKKkRmdgLbk/qYxkmmH6Z4eE8OoM0w3DM=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
@@ -53,8 +55,6 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91
github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL8sThn8IHr/sO+o=
github.com/go-playground/validator/v10 v10.23.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/golang-module/carbon/v2 v2.3.10 h1:C25x4A4UrIch6bisV3j37eU+op5+cp4gw/Fffv5c/FA=
-github.com/golang-module/carbon/v2 v2.3.10/go.mod h1:XDALX7KgqmHk95xyLeaqX9/LJGbfLATyruTziq68SZ8=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
@@ -85,13 +85,8 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
-github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
-github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
+github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
@@ -108,6 +103,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/internal/app/ddnsr53.go b/internal/app/ddnsr53.go
index b30a65dd..f7d96d71 100644
--- a/internal/app/ddnsr53.go
+++ b/internal/app/ddnsr53.go
@@ -14,7 +14,7 @@ import (
"github.com/crazy-max/ddns-route53/v2/pkg/route53"
"github.com/crazy-max/ddns-route53/v2/pkg/utl"
"github.com/crazy-max/ddns-route53/v2/pkg/wanip"
- "github.com/golang-module/carbon/v2"
+ "github.com/dromara/carbon/v2"
"github.com/robfig/cron/v3"
"github.com/rs/zerolog/log"
)
diff --git a/vendor/github.com/golang-module/carbon/v2/.editorconfig b/vendor/github.com/dromara/carbon/v2/.editorconfig
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/.editorconfig
rename to vendor/github.com/dromara/carbon/v2/.editorconfig
diff --git a/vendor/github.com/golang-module/carbon/v2/LICENSE b/vendor/github.com/dromara/carbon/v2/LICENSE
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/LICENSE
rename to vendor/github.com/dromara/carbon/v2/LICENSE
diff --git a/vendor/github.com/golang-module/carbon/v2/README.cn.md b/vendor/github.com/dromara/carbon/v2/README.cn.md
similarity index 91%
rename from vendor/github.com/golang-module/carbon/v2/README.cn.md
rename to vendor/github.com/dromara/carbon/v2/README.cn.md
index ec3c7cb0..50172017 100644
--- a/vendor/github.com/golang-module/carbon/v2/README.cn.md
+++ b/vendor/github.com/dromara/carbon/v2/README.cn.md
@@ -1,53 +1,50 @@
# Carbon #
-[![Carbon Release](https://img.shields.io/github/release/golang-module/carbon.svg)](https://github.com/golang-module/carbon/releases)
-[![Go Test](https://github.com/golang-module/carbon/actions/workflows/test.yml/badge.svg)](https://github.com/golang-module/carbon/actions)
-[![Go Report Card](https://goreportcard.com/badge/github.com/golang-module/carbon/v2)](https://goreportcard.com/report/github.com/golang-module/carbon/v2)
-[![Go Coverage](https://codecov.io/gh/golang-module/carbon/branch/master/graph/badge.svg)](https://codecov.io/gh/golang-module/carbon)
-[![Goproxy.cn](https://goproxy.cn/stats/github.com/golang-module/carbon/badges/download-count.svg)](https://goproxy.cn)
-[![Carbon Doc](https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/golang-module/carbon/v2)
-[![License](https://img.shields.io/github/license/golang-module/carbon)](https://github.com/golang-module/carbon/blob/master/LICENSE)
+[![Carbon Release](https://img.shields.io/github/release/dromara/carbon.svg)](https://github.com/dromara/carbon/releases)
+[![Go Test](https://github.com/dromara/carbon/actions/workflows/test.yml/badge.svg)](https://github.com/dromara/carbon/actions)
+[![Go Report Card](https://goreportcard.com/badge/github.com/dromara/carbon/v2)](https://goreportcard.com/report/github.com/dromara/carbon/v2)
+[![Go Coverage](https://codecov.io/gh/dromara/carbon/branch/master/graph/badge.svg)](https://codecov.io/gh/dromara/carbon)
+[![Carbon Doc](https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/dromara/carbon/v2)
+[![License](https://img.shields.io/github/license/dromara/carbon)](https://github.com/dromara/carbon/blob/master/LICENSE)
简体中文 | [English](README.md) | [日本語](README.jp.md)
-一个轻量级、语义化、对开发者友好的 golang 时间处理库,支持链式调用,已被 [awesome-go-cn](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") 收录
+#### 项目简介
-[github.com/golang-module/carbon](https://github.com/golang-module/carbon "github.com/golang-module/carbon")
+一个轻量级、语义化、对开发者友好的 golang 时间处理库,支持链式调用,已被 [awesome-go](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") 收录,并获得 `gitee` 2024 年最有价值项目(`GVP`)和 `gitcode` 2024 年度开源摘星计划 (`G-Star`) 项目
-[gitee.com/golang-module/carbon](https://gitee.com/golang-module/carbon "gitee.com/golang-module/carbon")
+#### 仓库地址
+
+[github.com/dromara/carbon](https://github.com/dromara/carbon "github.com/dromara/carbon")
+
+[gitee.com/dromara/carbon](https://gitee.com/dromara/carbon "gitee.com/dromara/carbon")
+
+[gitcode.com/dromara/carbon](https://gitcode.com/dromara/carbon "gitcode.com/dromara/carbon")
#### 安装使用
-##### Golang 版本大于等于 1.16 (推荐)
+##### go version >= 1.17
```go
// 使用 github 库
-go get -u github.com/golang-module/carbon/v2
-
-import "github.com/golang-module/carbon/v2"
+go get -u github.com/dromara/carbon/v2
+import "github.com/dromara/carbon/v2"
// 使用 gitee 库
-go get -u gitee.com/golang-module/carbon/v2
+go get -u gitee.com/dromara/carbon/v2
+import "gitee.com/dromara/carbon/v2"
-import "gitee.com/golang-module/carbon/v2"
+// 使用 gitcode 库
+go get -u gitcode.com/dromara/carbon/v2
+import "gitcode.com/dromara/carbon/v2"
```
-##### Golang 版本小于 1.16 (必须)
+`Carbon` 已经捐赠给了 [dromara](https://dromara.org/ "dromara") 组织,仓库地址发生了改变,如果之前用的路径是 `golang-module/carbon`,请在 `go.mod` 里将原地址更换为新路径,或执行如下命令
```go
-// 使用 github 库
-go get -u github.com/golang-module/carbon
-
-import "github.com/golang-module/carbon"
-
-// 使用 gitee 库
-go get -u gitee.com/golang-module/carbon
-
-import "gitee.com/golang-module/carbon"
+go mod edit -replace github.com/golang-module/carbon/v2=github.com/dromara/carbon/v2
```
-> v1 和 v2 版本区别请查阅 常见问题,v1 版本不再更新,仅维护。
-
#### 用法示例
> 假设当前时间为 2020-08-05 13:14:15.999999999 +0800 CST
@@ -59,11 +56,10 @@ carbon.SetDefault(carbon.Default{
Layout: carbon.DateTimeLayout,
Timezone: carbon.PRC,
WeekStartsAt: carbon.Sunday,
- Locale: "zh-CN",
+ Locale: "zh-CN", // 取值范围:lang 目录下翻译文件名,不包含文件后缀
})
```
-
-> 如果没有设置,默认布局模板是 `2006-01-02 15:04:05`, 默认时区是 `Local`, 默认一周开始日期是 `Sunday(周日)`, 默认语言是 `en`
+> 建议在入口文件如 `main.go` 中设置
##### `Carbon` 和 `time.Time` 互转
@@ -581,6 +577,11 @@ tomorrow := carbon.Tomorrow()
carbon.Max(yesterday, today, tomorrow) // tomorrow
// 返回最小的 Carbon 实例
carbon.Min(yesterday, today, tomorrow) // yesterday
+
+// 返回 Carbon 的最大值
+carbon.MaxValue().ToString() // 9999-12-31 23:59:59.999999999 +0000 UTC
+// 返回 Carbon 的最小值
+carbon.MinValue().ToString() // -9998-01-01 00:00:00 +0000 UTC
```
##### 时间判断
@@ -595,7 +596,7 @@ carbon.Parse("00:00:00").IsDST() // false
carbon.Parse("2023-01-01", "Australia/Brisbane").IsDST() // false
carbon.Parse("2023-01-01", "Australia/Sydney").IsDST() // true
-// 是否是零值时间
+// 是否是零值时间(0001-01-01 00:00:00 +0000 UTC)
carbon.Parse("").IsZero() // true
carbon.Parse("0").IsZero() // true
carbon.Parse("0000-00-00 00:00:00").IsZero() // true
@@ -1210,173 +1211,111 @@ carbon.Parse("2020-08-05 13:14:15").IsWinter() // false
```
##### JSON
-
-###### 场景一: 所有时间字段有相同的格式
```go
-carbon.SetDefault(carbon.Default{
- Layout: carbon.DateTimeLayout,
-})
-
type Person struct {
Name string `json:"name"`
- Age int `json:"age"`
-
- Field1 carbon.Carbon `json:"field1"`
- Field2 carbon.Carbon `json:"field2"`
- Field3 carbon.Carbon `json:"field3"`
- Field4 carbon.Carbon `json:"field4"`
-
- Field5 carbon.Carbon `json:"field5"`
- Field6 carbon.Carbon `json:"field6"`
- Field7 carbon.Carbon `json:"field7"`
- Field8 carbon.Carbon `json:"field8"`
+ Age int `json:"age"`
+ Birthday0 carbon.Carbon `json:"birthday0"`
+ Birthday1 carbon.DateTime `json:"birthday1"`
+ Birthday2 carbon.DateTimeMilli `json:"birthday2"`
+ Birthday3 carbon.DateTimeMicro `json:"birthday3"`
+ Birthday4 carbon.DateTimeNano `json:"birthday4"`
+ GraduatedAt1 carbon.Date `json:"graduated_at1"`
+ GraduatedAt2 carbon.DateMilli `json:"graduated_at2"`
+ GraduatedAt3 carbon.DateMicro `json:"graduated_at3"`
+ GraduatedAt4 carbon.DateNano `json:"graduated_at4"`
+ OperatedAt1 carbon.Time `json:"operated_at1"`
+ OperatedAt2 carbon.TimeMilli `json:"operated_at2"`
+ OperatedAt3 carbon.TimeMicro `json:"operated_at3"`
+ OperatedAt4 carbon.TimeNano `json:"operated_at4"`
+ CreatedAt1 carbon.Timestamp `json:"created_at1"`
+ CreatedAt2 carbon.TimestampMilli `json:"created_at2"`
+ CreatedAt3 carbon.TimestampMicro `json:"created_at3"`
+ CreatedAt4 carbon.TimestampNano `json:"created_at4"`
}
-now := carbon.Parse("2020-08-05 13:14:15", carbon.PRC)
person := Person {
- Name: "gouguoyin",
- Age: 18,
-
- Field1: now,
- Field2: now,
- Field3: now,
- Field4: now,
- Field5: now,
- Field6: now,
- Field7: now,
- Field8: now,
+ Name: "gouguoyin",
+ Age: 18,
+ Birthday0: carbon.Now().SubYears(18),
+ Birthday1: carbon.NewDateTime(carbon.Now().SubYears(18)),
+ Birthday2: carbon.NewDateTimeMilli(carbon.Now().SubYears(18)),
+ Birthday3: carbon.NewDateTimeMicro(carbon.Now().SubYears(18)),
+ Birthday4: carbon.NewDateTimeNano(carbon.Now().SubYears(18)),
+ GraduatedAt1: carbon.NewDate(carbon.Now()),
+ GraduatedAt2: carbon.NewDateMilli(carbon.Now()),
+ GraduatedAt3: carbon.NewDateMicro(carbon.Now()),
+ GraduatedAt4: carbon.NewDateNano(carbon.Now()),
+ OperatedAt1: carbon.NewTime(carbon.Now()),
+ OperatedAt2: carbon.NewTimeMilli(carbon.Now()),
+ OperatedAt3: carbon.NewTimeMicro(carbon.Now()),
+ OperatedAt4: carbon.NewTimeNano(carbon.Now()),
+ CreatedAt1: carbon.NewTimestamp(carbon.Now()),
+ CreatedAt2: carbon.NewTimestampMilli(carbon.Now()),
+ CreatedAt3: carbon.NewTimestampMicro(carbon.Now()),
+ CreatedAt4: carbon.NewTimestampNano(carbon.Now()),
}
-data, marshalErr := json.Marshal(person)
-if marshalErr != nil {
+data, err := json.Marshal(&person)
+if err != nil {
// 错误处理
- log.Fatal(marshalErr)
+ log.Fatal(err)
}
fmt.Printf("%s", data)
// 输出
{
"name": "gouguoyin",
"age": 18,
- "field1": "2020-08-05 13:14:15",
- "field2": "2020-08-05 13:14:15",
- "field3": "2020-08-05 13:14:15",
- "field4": "2020-08-05 13:14:15",
- "field5": "2020-08-05 13:14:15",
- "field6": "2020-08-05 13:14:15",
- "field7": "2020-08-05 13:14:15",
- "field8": "2020-08-05 13:14:15"
+ "birthday0": "2003-07-16 13:14:15",
+ "birthday1": "2003-07-16 13:14:15",
+ "birthday2": "2003-07-16 13:14:15.999",
+ "birthday3": "2003-07-16 13:14:15.999999",
+ "birthday4": "2003-07-16 13:14:15.999999999",
+ "graduated_at1": "2020-08-05",
+ "graduated_at2": "2020-08-05.999",
+ "graduated_at3": "2020-08-05.999999",
+ "graduated_at4": "2020-08-05.999999999",
+ "operated_at1": "13:14:15",
+ "operated_at2": "13:14:15.999",
+ "operated_at3": "13:14:15.999999",
+ "operated_at4": "13:14:15.999999999",
+ "created_at1": 1596604455,
+ "created_at2": 1596604455999,
+ "created_at3": 1596604455999999,
+ "created_at4": 1596604455999999999
}
-unmarshalErr := json.Unmarshal(data, &person)
-if unmarshalErr != nil {
+err := json.Unmarshal([]byte(data), &person)
+if err != nil {
// 错误处理
- log.Fatal(unmarshalErr)
+ log.Fatal(err)
}
-fmt.Printf("%s", person.Field1) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field2) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field3) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field4) // 2020-08-05 13:14:15
-
-fmt.Printf("%s", person.Field5) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field6) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field7) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field8) // 2020-08-05 13:14:15
-```
-
-###### 场景二: 不同时间字段有不同的格式
-
-> 所有支持的 type 值请点击 这里 查阅。 如果 `carbon` 标签没有设置,默认是 `layout:2006-01-02 15:04:05`;如果 `tz` 标签没有设置,默认是 `Local`
-
-```go
-type Person struct {
- Name string `json:"name"`
- Age int `json:"age"`
-
- Field1 carbon.Carbon `json:"field1"`
-
- Field2 carbon.Carbon `json:"field2" carbon:"type:date" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"type:time" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"type:dateTime" tz:"PRC"`
- // 或者
- Field2 carbon.Carbon `json:"field2" carbon:"layout:2006-01-02" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"layout:15:04:05" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
- // 或者
- Field2 carbon.Carbon `json:"field2" carbon:"format:Y-m-d" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"format:H:i:s" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
-
- Field5 carbon.Carbon `json:"field5" carbon:"type:timestamp" tz:"PRC"`
- Field6 carbon.Carbon `json:"field6" carbon:"type:timestampMilli" tz:"PRC"`
- Field7 carbon.Carbon `json:"field7" carbon:"type:timestampMicro" tz:"PRC"`
- Field8 carbon.Carbon `json:"field8" carbon:"type:timestampNano" tz:"PRC"`
-}
-
-now := Parse("2020-08-05 13:14:15", carbon.PRC)
-person := Person {
- Name: "gouguoyin",
- Age: 18,
-
- Field1: now,
- Field2: now,
- Field3: now,
- Field4: now,
- Field5: now,
- Field6: now,
- Field7: now,
- Field8: now,
-}
-
-loadErr := carbon.LoadTag(&person)
-if loadErr != nil {
- // 错误处理
- log.Fatal(loadErr)
-}
-data, marshalErr := json.Marshal(person)
-if marshalErr != nil {
- // 错误处理
- log.Fatal(marshalErr)
-}
-fmt.Printf("%s", data)
-// 输出
-{
- "name": "gouguoyin",
- "age": 18,
- "field1": "2020-08-05 13:14:15",
- "field2": "2020-08-05",
- "field3": "13:14:15",
- "field4": "2020-08-05 13:14:15",
- "field5": 1596604455,
- "field6": 1596604455999,
- "field7": 1596604455999999,
- "field8": 1596604455999999999
-}
-
-var person Person
-
-loadErr := carbon.LoadTag(&person)
-if loadErr != nil {
- // 错误处理
- log.Fatal(loadErr)
-}
-
-unmarshalErr := json.Unmarshal(data, &person)
-if unmarshalErr != nil {
- // 错误处理
- log.Fatal(unmarshalErr)
-}
-
-fmt.Printf("%s", person.Field1) // 2002-08-05 13:14:15
-fmt.Printf("%s", person.Field2) // 2020-08-05
-fmt.Printf("%s", person.Field3) // 13:14:15
-fmt.Printf("%s", person.Field4) // 2002-08-05 13:14:15
-
-fmt.Printf("%d", person.Field5) // 1596604455
-fmt.Printf("%d", person.Field6) // 1596604455999
-fmt.Printf("%d", person.Field7) // 1596604455999999
-fmt.Printf("%d", person.Field8) // 1596604455999999999
-
+person.Birthday0.String() // 2003-07-16 13:14:15
+person.Birthday1.String() // 2003-07-16 13:14:15
+person.Birthday2.String() // 2003-07-16 13:14:15.999
+person.Birthday3.String() // 2003-07-16 13:14:15.999999
+person.Birthday4.String() // 2003-07-16 13:14:15.999999999
+
+person.GraduatedAt1.String() // 2020-08-05
+person.GraduatedAt2.String() // 2020-08-05.999
+person.GraduatedAt3.String() // 2020-08-05.999999
+person.GraduatedAt4.String() // 2020-08-05.999999999
+
+person.OperatedAt1.String() // 13:14:15
+person.OperatedAt2.String() // 13:14:15.999
+person.OperatedAt3.String() // 13:14:15.999999
+person.OperatedAt4.String() // 13:14:15.999999999
+
+person.CreatedAt1.String() // "1596604455"
+person.CreatedAt2.String() // "1596604455999"
+person.CreatedAt3.String() // "1596604455999999"
+person.CreatedAt4.String() // "1596604455999999999"
+
+person.CreatedAt1.Int64() // 1596604455
+person.CreatedAt2.Int64() // 1596604455999
+person.CreatedAt3.Int64() // 1596604455999999
+person.CreatedAt4.Int64() // 1596604455999999999
```
##### 日历
@@ -1414,6 +1353,10 @@ fmt.Printf("%d", person.Field8) // 1596604455999999999
* [越南语(vi)](./lang/vi.json "越南语"): 由 [culy247](https://github.com/culy247 "culy247") 翻译
* [印地语(hi)](./lang/hi.json "印地语"): 由 [chauhan17nitin](https://github.com/chauhan17nitin "chauhan17nitin") 翻译
* [波兰语(pl)](./lang/pl.json "波兰语"): 由 [gouguoyin](https://github.com/gouguoyin "gouguoyin") 翻译
+* [保加利亚语(bg)](./lang/bg.json "保加利亚语"): 由 [yuksbg](https://github.com/yuksbg "yuksbg") 翻译
+* [阿拉伯语(ar)](./lang/bg.json "阿拉伯语"): 由 [zumoshi](https://github.com/yuksbg "zumoshi") 翻译
+* [匈牙利语(hu)](./lang/hu.json "匈牙利语"): 由 [kenlas](https://github.com/kenlas "kenlas") 翻译
+* [丹麦语(dk)](./lang/dk.json "丹麦语"): 由 [Munk91](https://github.com/Munk91 "Munk91") 翻译
目前支持的方法有
@@ -1613,6 +1556,7 @@ COPY ./zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
#### 参考项目
* [briannesbitt/carbon](https://github.com/briannesbitt/Carbon)
+* [nodatime/nodatime](https://github.com/nodatime/nodatime)
* [jinzhu/now](https://github.com/jinzhu/now)
* [goframe/gtime](https://github.com/gogf/gf/tree/master/os/gtime)
* [jodaOrg/joda-time](https://github.com/jodaOrg/joda-time)
@@ -1623,7 +1567,7 @@ COPY ./zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
#### 贡献者
感谢以下所有为 `Carbon` 做出贡献的人:
-
+
#### 赞助
diff --git a/vendor/github.com/golang-module/carbon/v2/README.jp.md b/vendor/github.com/dromara/carbon/v2/README.jp.md
similarity index 72%
rename from vendor/github.com/golang-module/carbon/v2/README.jp.md
rename to vendor/github.com/dromara/carbon/v2/README.jp.md
index 3cb06671..9300c1ad 100644
--- a/vendor/github.com/golang-module/carbon/v2/README.jp.md
+++ b/vendor/github.com/dromara/carbon/v2/README.jp.md
@@ -1,107 +1,102 @@
-# Carbon #
+# Carbon
-[![Carbon Release](https://img.shields.io/github/release/golang-module/carbon.svg)](https://github.com/golang-module/carbon/releases)
-[![Go Test](https://github.com/golang-module/carbon/actions/workflows/test.yml/badge.svg)](https://github.com/golang-module/carbon/actions)
-[![Go Report Card](https://goreportcard.com/badge/github.com/golang-module/carbon/v2)](https://goreportcard.com/report/github.com/golang-module/carbon/v2)
-[![Go Coverage](https://codecov.io/gh/golang-module/carbon/branch/master/graph/badge.svg)](https://codecov.io/gh/golang-module/carbon)
-[![Goproxy.cn](https://goproxy.cn/stats/github.com/golang-module/carbon/badges/download-count.svg)](https://goproxy.cn)
-[![Carbon Doc](https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/golang-module/carbon/v2)
-[![License](https://img.shields.io/github/license/golang-module/carbon)](https://github.com/golang-module/carbon/blob/master/LICENSE)
+[![Carbon Release](https://img.shields.io/github/release/dromara/carbon.svg)](https://github.com/dromara/carbon/releases)
+[![Go Test](https://github.com/dromara/carbon/actions/workflows/test.yml/badge.svg)](https://github.com/dromara/carbon/actions)
+[![Go Report Card](https://goreportcard.com/badge/github.com/dromara/carbon/v2)](https://goreportcard.com/report/github.com/dromara/carbon/v2)
+[![Go Coverage](https://codecov.io/gh/dromara/carbon/branch/master/graph/badge.svg)](https://codecov.io/gh/dromara/carbon)
+[![Carbon Doc](https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/dromara/carbon/v2)
+[![License](https://img.shields.io/github/license/dromara/carbon)](https://github.com/dromara/carbon/blob/master/LICENSE)
日本語 | [English](README.md) | [简体中文](README.cn.md)
-軽量でセマンティックで開発者に優しい golang 時間処理ライブラリ
+#### イントロ
-Carbon は [awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go") に収録されています, よかったら, スターをください
+シンプルでセマンティックで開発者に優しい golang 時間処理ライブラリ
-[github.com/golang-module/carbon](https://github.com/golang-module/carbon "github.com/golang-module/carbon")
+Carbon は [awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go") に含まれています
-[gitee.com/golang-module/carbon](https://gitee.com/golang-module/carbon "gitee.com/golang-module/carbon")
+#### リポジトリ
-#### インストール使用
+[github.com/dromara/carbon](https://github.com/dromara/carbon "github.com/dromara/carbon")
-##### Golangバージョンは1.16以上です (推奨)
+[gitee.com/dromara/carbon](https://gitee.com/dromara/carbon "gitee.com/dromara/carbon")
-```go
-// github倉庫を使う
-go get -u github.com/golang-module/carbon/v2
+[gitcode.com/dromara/carbon](https://gitcode.com/dromara/carbon "gitcode.com/dromara/carbon")
+
+#### インストール
-import "github.com/golang-module/carbon/v2"
+##### go version >= 1.17
+```go
+// github から使う
+go get -u github.com/dromara/carbon/v2
+import "github.com/dromara/carbon/v2"
-// gitee倉庫を使う
-go get -u gitee.com/golang-module/carbon/v2
+// gitee から使う
+go get -u gitee.com/dromara/carbon/v2
+import "gitee.com/dromara/carbon/v2"
-import "gitee.com/golang-module/carbon/v2"
+// gitcode から使う
+go get -u gitcode.com/dromara/carbon/v2
+import "gitcode.com/dromara/carbon/v2"
```
-##### Golangバージョンは1.16より小さいです (必要)
+`Carbon` は [dromara](https://dromara.org/ "dromara") 組織に寄付されたためリポジトリのURLが変更されました。以前のリポジトリ `golang-module/carbon` を使用している場合は`go.mod`で新しいリポジトリURLに変更するか下記コマンドを実行します
```go
-// github倉庫を使う
-go get -u github.com/golang-module/carbon
-
-import "github.com/golang-module/carbon"
-
-// gitee倉庫を使う
-go get -u gitee.com/golang-module/carbon
-
-import "gitee.com/golang-module/carbon"
+go mod edit -replace github.com/golang-module/carbon/v2=github.com/dromara/carbon/v2
```
-> v1とv2の違いについては、人気のある問題をご覧ください,v1 は更新されなくなり、維持されるだけです。
-
-人気のある問題
-#### 使い方の例
+#### 使い方と例
> 現在時刻が 2020-08-05 13:14:15.999999999 +0800 CST であると仮定します。
-##### グローバル・デフォルトの設定
+##### グローバルのデフォルト値設定
```go
carbon.SetDefault(carbon.Default{
Layout: carbon.DateTimeLayout,
- Timezone: carbon.PRC,
+ Timezone: carbon.Japan,
WeekStartsAt: carbon.Sunday,
- Locale: "jp",
+ Locale: "jp", // 値の範囲: langディレクトリ下の翻訳ファイル名でファイル拡張子は含まない
})
```
-> 設定されていない場合,デフォルトのレイアウト テンプレートは `2006-01-02 15:04:05`,デフォルトのタイムゾーンは `Local`,デフォルトの週の開始日は `日曜日`,デフォルトの言語は `en` です。
+>エントリファイル(` main.go `など)に設定することをお勧めします
-##### Carbon と time.Time 交換
+##### Carbon と time.Time 間の変換
```go
-// 標準の time.Time を Carbon に変換します
+// time.Time を Carbon に変換
carbon.CreateFromStdTime(time.Now())
-// Carbon を標準の time.Time に変換します
+// Carbon を time.Time に変換
carbon.Now().StdTime()
```
-##### 昨日、今日、明日
+##### 昨日、現在、明日
```go
-// 今日の瞬間
+// 現在時刻
fmt.Printf("%s", carbon.Now()) // 2020-08-05 13:14:15
carbon.Now().String() // 2020-08-05 13:14:15
carbon.Now().ToString() // 2020-08-05 13:14:15 +0800 CST
carbon.Now().ToDateTimeString() // 2020-08-05 13:14:15
-// 今日の日付
+// 現在の日付
carbon.Now().ToDateString() // 2020-08-05
-// 今日の時間
+// 現在の時間
carbon.Now().ToTimeString() // 13:14:15
-// タイムゾーン指定の今日
+// タイムゾーン指定の現在
carbon.Now(Carbon.NewYork).ToDateTimeString() // 2020-08-05 14:14:15
-// 今日は秒タイムスタンプ
+// 現在の秒タイムスタンプ
carbon.Now().Timestamp() // 1596604455
-// 今日のミリ秒タイムスタンプ
+// 現在のミリ秒タイムスタンプ
carbon.Now().TimestampMilli() // 1596604455999
-// 今日のマイクロ秒タイムスタンプ
+// 現在のマイクロ秒タイムスタンプ
carbon.Now().TimestampMicro() // 1596604455999999
-// 今日のナノ秒タイムスタンプ
+// 現在のナノ秒タイムスタンプ
carbon.Now().TimestampNano() // 1596604455999999999
-// 昨日の今は
+// 昨日の現在時刻
fmt.Printf("%s", carbon.Yesterday()) // 2020-08-04 13:14:15
carbon.Yesterday().String() // 2020-08-04 13:14:15
carbon.Yesterday().ToString() // 2020-08-04 13:14:15 +0800 CST
@@ -123,7 +118,7 @@ carbon.Yesterday().TimestampMicro() // 1596518055999999
// 昨日のナノ秒タイムスタンプ
carbon.Yesterday().TimestampNano() // 1596518055999999999
-// 明日の今は
+// 明日の現在時刻
fmt.Printf("%s", carbon.Tomorrow()) // 2020-08-06 13:14:15
carbon.Tomorrow().String() // 2020-08-06 13:14:15
carbon.Tomorrow().ToString() // 2020-08-06 13:14:15 +0800 CST
@@ -146,50 +141,50 @@ carbon.Tomorrow().TimestampMicro() // 1596690855999999
carbon.Tomorrow().TimestampNano() // 1596690855999999999
```
-##### Carbon オブジェクトを作成する
+##### Carbon インスタンスを作成する
```go
-// 秒タイムスタンプから Carbon オブジェクトを作成します
+// 秒タイムスタンプから Carbon インスタンスを作成します
carbon.CreateFromTimestamp(-1).ToString() // 1970-01-01 07:59:59 +0800 CST
carbon.CreateFromTimestamp(0).ToString() // 1970-01-01 08:00:00 +0800 CST
carbon.CreateFromTimestamp(1).ToString() // 1970-01-01 08:00:01 +0800 CST
carbon.CreateFromTimestamp(1649735755).ToString() // 2022-04-12 11:55:55 +0800 CST
-// ミリ秒のタイムスタンプから Carbon オブジェクトを作成します
+// ミリ秒のタイムスタンプから Carbon インスタンスを作成します
carbon.CreateFromTimestampMilli(1649735755981).ToString() // 2022-04-12 11:55:55.981 +0800 CST
-// マイクロ秒タイムスタンプから Carbon オブジェクトを作成します
+// マイクロ秒タイムスタンプから Carbon インスタンスを作成します
carbon.CreateFromTimestampMicro(1649735755981566).ToString() // 2022-04-12 11:55:55.981566 +0800 CST
-// ナノタイムスタンプから Carbon オブジェクトを作成します
+// ナノタイムスタンプから Carbon インスタンスを作成します
carbon.CreateFromTimestampNano(1649735755981566000).ToString() // 2022-04-12 11:55:55.981566 +0800 CST
-// 年月日から分秒で Carbon オブジェクトを作成します
+// 日付と時間から Carbon インスタンスを作成します
carbon.CreateFromDateTime(2020, 8, 5, 13, 14, 15).ToDateTimeString() // 2020-08-05 13:14:15
-// 年月日から分秒で Carbon オブジェクトを作成します,ミリ秒を含む
+// 日付と時間、ミリ秒から Carbon インスタンスを作成します
carbon.CreateFromDateTimeMilli(2020, 1, 1, 13, 14, 15, 999).ToString() // 2020-01-01 13:14:15.999 +0800 CST
-// 年月日から分秒で Carbon オブジェクトを作成します,マイクロ秒を含む
+// 日付と時間、マイクロ秒から Carbon インスタンスを作成します
carbon.CreateFromDateTimeMicro(2020, 1, 1, 13, 14, 15, 999999).ToString() // 2020-01-01 13:14:15.999999 +0800 CST
-// 年月日から分秒で Carbon オブジェクトを作成します,ナノ秒を含む
+// 日付と時間、ナノ秒から Carbon インスタンスを作成します
carbon.CreateFromDateTimeNano(2020, 1, 1, 13, 14, 15, 999999999).ToString() // 2020-01-01 13:14:15.999999999 +0800 CST
-// 年月日から Carbon オブジェクトを作成します
+// 日付から Carbon インスタンスを作成します
carbon.CreateFromDate(2020, 8, 5).ToString() // 2020-08-05 00:00:00 +0800 CST
-// 年月日から Carbon オブジェクトを作成します,ミリ秒を含む
+// 日付とミリ秒から Carbon インスタンスを作成します
carbon.CreateFromDateMilli(2020, 8, 5, 999).ToString() // 2020-08-05 00:00:00.999 +0800 CST
-// 年月日から Carbon オブジェクトを作成します,マイクロ秒を含む
+// 日付とマイクロ秒から Carbon インスタンスを作成します
carbon.CreateFromDateMicro(2020, 8, 5, 999999).ToString() // 2020-08-05 00:00:00.999999 +0800 CST
-// 年月日から Carbon オブジェクトを作成します,ナノ秒を含む
+// 日付とナノ秒から Carbon インスタンスを作成します
carbon.CreateFromDateNano(2020, 8, 5, 999999999).ToString() // 2020-08-05 00:00:00.999999999 +0800 CST
-// 時分秒から Carbon オブジェクトを作成します(年月日のデフォルトは現在の年月日です)
+// 時間から Carbon インスタンスを作成します(日付のデフォルトは現在の年月日です)
carbon.CreateFromTime(13, 14, 15).ToString() // 2020-08-05 13:14:15 +0800 CST
-// 時分秒から Carbon オブジェクトを作成します(年月日のデフォルトは現在の年月日です),ミリ秒を含む
+// 時間、ミリ秒から Carbon インスタンスを作成します(年月日のデフォルトは現在の年月日です)
carbon.CreateFromTimeMilli(13, 14, 15, 999).ToString() // 2020-08-05 13:14:15.999 +0800 CST
-// 時分秒から Carbon オブジェクトを作成します(年月日のデフォルトは現在の年月日です),マイクロ秒を含む
+// 時間、マイクロ秒から Carbon インスタンスを作成します(年月日のデフォルトは現在の年月日です)
carbon.CreateFromTimeMicro(13, 14, 15, 999999).ToString() // 2020-08-05 13:14:15.999999 +0800 CST
-// 時分秒から Carbon オブジェクトを作成します(年月日のデフォルトは現在の年月日です),ナノ秒を含む
+// 時間、ナノ秒から Carbon インスタンスを作成します(年月日のデフォルトは現在の年月日です)
carbon.CreateFromTimeNano(13, 14, 15, 999999999).ToString() // 2020-08-05 13:14:15.999999999 +0800 CST
```
-##### 時間文字列を Carbon オブジェクトに解析します
+##### 時間文字列を Carbon インスタンスにパース
```go
carbon.Parse("").ToDateTimeString() // 空の文字列
@@ -237,7 +232,7 @@ carbon.Parse("20200805131415.999999+08:00").ToString() // 2020-08-05 13:14:15.99
carbon.Parse("20200805131415.999999999+08:00").ToString() // 2020-08-05 13:14:15.999999999 +0800 CST
```
-##### 文字をフォーマットして文字列を Carbon オブジェクトに解析します
+##### フォーマットして文字列を Carbon インスタンスにパース
```go
carbon.ParseByFormat("2020|08|05 13|14|15", "Y|m|d H|i|s").ToDateTimeString() // 2020-08-05 13:14:15
@@ -245,7 +240,7 @@ carbon.ParseByFormat("It is 2020-08-05 13:14:15", "\\I\\t \\i\\s Y-m-d H:i:s").T
carbon.ParseByFormat("今天是 2020年08月05日13时14分15秒", "今天是 Y年m月d日H时i分s秒").ToDateTimeString() // 2020-08-05 13:14:15
```
-##### レイアウト文字を使用して文字列を Carbon オブジェクトに解析します
+##### レイアウトし、文字列を Carbon インスタンスにパース
```go
carbon.ParseByLayout("2020|08|05 13|14|15", "2006|01|02 15|04|05").ToDateTimeString() // 2020-08-05 13:14:15
@@ -254,303 +249,303 @@ carbon.ParseByLayout("今天是 2020年08月05日13时14分15秒", "今天是 20
carbon.ParseByLayout("2020-08-05 13:14:15", "2006-01-02 15:04:05", carbon.Tokyo).ToDateTimeString() // 2020-08-05 14:14:15
```
-##### 始まりと終わり
+##### 境界
```go
-// 世紀の始まり
+// 世紀始め
carbon.Parse("2020-08-05 13:14:15").StartOfCentury().ToDateTimeString() // 2000-01-01 00:00:00
-// 世紀の終わり
+// 世紀終わり
carbon.Parse("2020-08-05 13:14:15").EndOfCentury().ToDateTimeString() // 2999-12-31 23:59:59
-// 十年の始まり
+// 十年紀始め
carbon.Parse("2020-08-05 13:14:15").StartOfDecade().ToDateTimeString() // 2020-01-01 00:00:00
carbon.Parse("2021-08-05 13:14:15").StartOfDecade().ToDateTimeString() // 2020-01-01 00:00:00
carbon.Parse("2029-08-05 13:14:15").StartOfDecade().ToDateTimeString() // 2020-01-01 00:00:00
-// 十年の終わり
+// 十年紀終わり
carbon.Parse("2020-08-05 13:14:15").EndOfDecade().ToDateTimeString() // 2029-12-31 23:59:59
carbon.Parse("2021-08-05 13:14:15").EndOfDecade().ToDateTimeString() // 2029-12-31 23:59:59
carbon.Parse("2029-08-05 13:14:15").EndOfDecade().ToDateTimeString() // 2029-12-31 23:59:59
-// 今年の始まり
+// 今年始め
carbon.Parse("2020-08-05 13:14:15").StartOfYear().ToDateTimeString() // 2020-01-01 00:00:00
-// 今年の終わり
+// 今年終わり
carbon.Parse("2020-08-05 13:14:15").EndOfYear().ToDateTimeString() // 2020-12-31 23:59:59
-// 季度の始まり
+// 四半期始め
carbon.Parse("2020-08-05 13:14:15").StartOfQuarter().ToDateTimeString() // 2020-07-01 00:00:00
-// 季度の終わり
+// 四半期終わり
carbon.Parse("2020-08-05 13:14:15").EndOfQuarter().ToDateTimeString() // 2020-09-30 23:59:59
-// 本月の始まり
+// 月始め
carbon.Parse("2020-08-05 13:14:15").StartOfMonth().ToDateTimeString() // 2020-08-01 00:00:00
-// 本月の終わり
+// 月終わり
carbon.Parse("2020-08-05 13:14:15").EndOfMonth().ToDateTimeString() // 2020-08-31 23:59:59
-// 本周の始まり
+// 周始め
carbon.Parse("2020-08-05 13:14:15").StartOfWeek().ToDateTimeString() // 2020-08-02 00:00:00
carbon.Parse("2020-08-05 13:14:15").SetWeekStartsAt(carbon.Sunday).StartOfWeek().ToDateTimeString() // 2020-08-02 00:00:00
carbon.Parse("2020-08-05 13:14:15").SetWeekStartsAt(carbon.Monday).StartOfWeek().ToDateTimeString() // 2020-08-03 00:00:00
-// 本周の終わり
+// 周終わり
carbon.Parse("2020-08-05 13:14:15").EndOfWeek().ToDateTimeString() // 2020-08-08 23:59:59
carbon.Parse("2020-08-05 13:14:15").SetWeekStartsAt(carbon.Sunday).EndOfWeek().ToDateTimeString() // 2020-08-08 23:59:59
carbon.Parse("2020-08-05 13:14:15").SetWeekStartsAt(carbon.Monday).EndOfWeek().ToDateTimeString() // 2020-08-09 23:59:59
-// 本日の始まり
+// 日始め
carbon.Parse("2020-08-05 13:14:15").StartOfDay().ToDateTimeString() // 2020-08-05 00:00:00
-// 本日の終わり
+// 日終わり
carbon.Parse("2020-08-05 13:14:15").EndOfDay().ToDateTimeString() // 2020-08-05 23:59:59
-// 時間の始まり
+// 時間始め
carbon.Parse("2020-08-05 13:14:15").StartOfHour().ToDateTimeString() // 2020-08-05 13:00:00
-// 時間の終わり
+// 時間終わり
carbon.Parse("2020-08-05 13:14:15").EndOfHour().ToDateTimeString() // 2020-08-05 13:59:59
-// 分钟の始まり
+// 分始め
carbon.Parse("2020-08-05 13:14:15").StartOfMinute().ToDateTimeString() // 2020-08-05 13:14:00
-// 分钟の終わり
+// 分終わり
carbon.Parse("2020-08-05 13:14:15").EndOfMinute().ToDateTimeString() // 2020-08-05 13:14:59
-// 本秒の始まり
+// 秒始め
carbon.Parse("2020-08-05 13:14:15").StartOfSecond().ToString() // 2020-08-05 13:14:15 +0800 CST
-// 本秒の終わり
+// 秒終わり
carbon.Parse("2020-08-05 13:14:15").EndOfSecond().ToString() // 2020-08-05 13:14:15.999999999 +0800 CST
```
-##### 追加と減らす
+##### 大きな時間更新
```go
-// 三ヶ世紀を追加
+// 3世紀追加
carbon.Parse("2020-02-29 13:14:15").AddCenturies(3).ToDateTimeString() // 2320-02-29 13:14:15
-// 三ヶ世紀を追加(オーバーフローなし)
+// 3世紀追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddCenturiesNoOverflow(3).ToDateTimeString() // 2320-02-29 13:14:15
-// 一ヶ世紀を追加
+// 1世紀追加
carbon.Parse("2020-02-29 13:14:15").AddCentury().ToDateTimeString() // 2120-02-29 13:14:15
-// 一ヶ世紀を追加(オーバーフローなし)
+// 1世紀追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddCenturyNoOverflow().ToDateTimeString() // 2120-02-29 13:14:15
-// 三ヶ世紀を減らす
+// 3世紀減らす
carbon.Parse("2020-02-29 13:14:15").SubCenturies(3).ToDateTimeString() // 1720-02-29 13:14:15
-// 三ヶ世紀を減らす(オーバーフローなし)
+// 3世紀減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubCenturiesNoOverflow(3).ToDateTimeString() // 1720-02-29 13:14:15
-// 一ヶ世紀を減らす
+// 1世紀減らす
carbon.Parse("2020-02-29 13:14:15").SubCentury().ToDateTimeString() // 1920-02-29 13:14:15
-// 一ヶ世紀を減らす(オーバーフローなし)
+// 1世紀減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubCenturyNoOverflow().ToDateTimeString() // 1920-02-29 13:14:15
-// 三ヶ年代を追加
+// 30年紀追加
carbon.Parse("2020-02-29 13:14:15").AddDecades(3).ToDateTimeString() // 2050-03-01 13:14:15
-// 三ヶ年代を追加(オーバーフローなし)
+// 30年紀追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddDecadesNoOverflow(3).ToDateTimeString() // 2050-02-28 13:14:15
-// 一ヶ年代を追加
+// 10年紀追加
carbon.Parse("2020-02-29 13:14:15").AddDecade().ToDateTimeString() // 2030-03-01 13:14:15
-// 一ヶ年代を追加(オーバーフローなし)
+// 10年紀追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddDecadeNoOverflow().ToDateTimeString() // 2030-02-28 13:14:15
-// 三ヶ年代を減らす
+// 30年紀減らす
carbon.Parse("2020-02-29 13:14:15").SubDecades(3).ToDateTimeString() // 1990-03-01 13:14:15
-// 三ヶ年代を減らす(オーバーフローなし)
+// 30年紀減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubDecadesNoOverflow(3).ToDateTimeString() // 1990-02-28 13:14:15
-// 一ヶ年代を減らす
+// 10年紀減らす
carbon.Parse("2020-02-29 13:14:15").SubDecade().ToDateTimeString() // 2010-03-01 13:14:15
-// 一ヶ年代を減らす(オーバーフローなし)
+// 10年紀減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubDecadeNoOverflow().ToDateTimeString() // 2010-02-28 13:14:15
-// 三か年を追加
+// 3年追加
carbon.Parse("2020-02-29 13:14:15").AddYears(3).ToDateTimeString() // 2023-03-01 13:14:15
-// 三か年を追加(オーバーフローなし)
+// 3年追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddYearsNoOverflow(3).ToDateTimeString() // 2023-02-28 13:14:15
-// 一か年を追加
+// 1年追加
carbon.Parse("2020-02-29 13:14:15").AddYear().ToDateTimeString() // 2021-03-01 13:14:15
-// 一か年を追加(オーバーフローなし)
+// 1年追加追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddYearNoOverflow().ToDateTimeString() // 2021-02-28 13:14:15
-// 三か年を減らす
+// 3年減らす
carbon.Parse("2020-02-29 13:14:15").SubYears(3).ToDateTimeString() // 2017-03-01 13:14:15
-// 三か年を減らす(オーバーフローなし)
+// 3年減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubYearsNoOverflow(3).ToDateTimeString() // 2017-02-28 13:14:15
-// 一か年を減らす
+// 1年減らす
carbon.Parse("2020-02-29 13:14:15").SubYear().ToDateTimeString() // 2019-03-01 13:14:15
-// 一か年を減らす(オーバーフローなし)
+// 1年減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubYearNoOverflow().ToDateTimeString() // 2019-02-28 13:14:15
-// 三ヶ四半期を追加
+// 3四半期追加
carbon.Parse("2019-05-31 13:14:15").AddQuarters(3).ToDateTimeString() // 2020-03-02 13:14:15
-// 三ヶ四半期を追加(オーバーフローなし)
+// 3四半期追加(オーバーフローなし)
carbon.Parse("2019-05-31 13:14:15").AddQuartersNoOverflow(3).ToDateTimeString() // 2020-02-29 13:14:15
-// 一ヶ四半期を追加
+// 1四半期追加
carbon.Parse("2019-11-30 13:14:15").AddQuarter().ToDateTimeString() // 2020-03-01 13:14:15
-// 一ヶ四半期を追加(オーバーフローなし)
+// 1四半期追加(オーバーフローなし)
carbon.Parse("2019-11-30 13:14:15").AddQuarterNoOverflow().ToDateTimeString() // 2020-02-29 13:14:15
-// 三ヶ四半期を減らす
+// 3四半期減らす
carbon.Parse("2019-08-31 13:14:15").SubQuarters(3).ToDateTimeString() // 2019-03-03 13:14:15
-// 三ヶ四半期を減らす(オーバーフローなし)
+// 3四半期減らす(オーバーフローなし)
carbon.Parse("2019-08-31 13:14:15").SubQuartersNoOverflow(3).ToDateTimeString() // 2019-02-28 13:14:15
-// 一ヶ四半期を減らす
+// 1四半期減らす
carbon.Parse("2020-05-31 13:14:15").SubQuarter().ToDateTimeString() // 2020-03-02 13:14:15
-// 一ヶ四半期を減らす(オーバーフローなし)
+// 1四半期減らす(オーバーフローなし)
carbon.Parse("2020-05-31 13:14:15").SubQuarterNoOverflow().ToDateTimeString() // 2020-02-29 13:14:15
-// 三ヶ月を追加
+// 3ヶ月追加
carbon.Parse("2020-02-29 13:14:15").AddMonths(3).ToDateTimeString() // 2020-05-29 13:14:15
-// 三ヶ月を追加(オーバーフローなし)
+// 3ヶ月追加(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").AddMonthsNoOverflow(3).ToDateTimeString() // 2020-05-29 13:14:15
-// 一ヶ月を追加
+// 1ヶ月追加
carbon.Parse("2020-01-31 13:14:15").AddMonth().ToDateTimeString() // 2020-03-02 13:14:15
-// 一ヶ月を追加(オーバーフローなし)
+// 1ヶ月追加(オーバーフローなし)
carbon.Parse("2020-01-31 13:14:15").AddMonthNoOverflow().ToDateTimeString() // 2020-02-29 13:14:15
-// 三ヶ月を減らす
+// 3ヶ月減らす
carbon.Parse("2020-02-29 13:14:15").SubMonths(3).ToDateTimeString() // 2019-11-29 13:14:15
-// 三ヶ月を減らす(オーバーフローなし)
+// 3ヶ月減らす(オーバーフローなし)
carbon.Parse("2020-02-29 13:14:15").SubMonthsNoOverflow(3).ToDateTimeString() // 2019-11-29 13:14:15
-// 一ヶ月を減らす
+// 1ヶ月減らす
carbon.Parse("2020-03-31 13:14:15").SubMonth().ToDateTimeString() // 2020-03-02 13:14:15
-// 一か月を減らす(オーバーフローなし)
+// 1か月減らす(オーバーフローなし)
carbon.Parse("2020-03-31 13:14:15").SubMonthNoOverflow().ToDateTimeString() // 2020-02-29 13:14:15
-// 三か週間を追加
+// 3週間追加
carbon.Parse("2020-02-29 13:14:15").AddWeeks(3).ToDateTimeString() // 2020-03-21 13:14:15
-// 一か週間を追加
+// 1週間追加
carbon.Parse("2020-02-29 13:14:15").AddWeek().ToDateTimeString() // 2020-03-07 13:14:15
-// 三か週間を減らす
+// 3週間減らす
carbon.Parse("2020-02-29 13:14:15").SubWeeks(3).ToDateTimeString() // 2020-02-08 13:14:15
-// 一か週間を減らす
+// 1週間減らす
carbon.Parse("2020-02-29 13:14:15").SubWeek().ToDateTimeString() // 2020-02-22 13:14:15
-// 三か日間を追加
+// 3日追加
carbon.Parse("2020-08-05 13:14:15").AddDays(3).ToDateTimeString() // 2020-08-08 13:14:15
-// 一か日間を追加
+// 1日追加
carbon.Parse("2020-08-05 13:14:15").AddDay().ToDateTimeString() // 2020-08-05 13:14:15
-// 三か日間を減らす
+// 3日減らす
carbon.Parse("2020-08-05 13:14:15").SubDays(3).ToDateTimeString() // 2020-08-02 13:14:15
-// 一か日間を減らす
+// 1日減らす
carbon.Parse("2020-08-05 13:14:15").SubDay().ToDateTimeString() // 2020-08-04 13:14:15
-// 三か時間を追加
+// 3時間追加
carbon.Parse("2020-08-05 13:14:15").AddHours(3).ToDateTimeString() // 2020-08-05 16:14:15
-// 二か時間半を追加
+// 2時間半追加
carbon.Parse("2020-08-05 13:14:15").AddDuration("2.5h").ToDateTimeString() // 2020-08-05 15:44:15
carbon.Parse("2020-08-05 13:14:15").AddDuration("2h30m").ToDateTimeString() // 2020-08-05 15:44:15
-// 一か時間を追加
+// 1時間追加
carbon.Parse("2020-08-05 13:14:15").AddHour().ToDateTimeString() // 2020-08-05 14:14:15
-// 三か時間を減らす
+// 3時間減らす
carbon.Parse("2020-08-05 13:14:15").SubHours(3).ToDateTimeString() // 2020-08-05 10:14:15
-// 二か時間半を減らす
+// 2時間半減らす
carbon.Parse("2020-08-05 13:14:15").SubDuration("2.5h").ToDateTimeString() // 2020-08-05 10:44:15
carbon.Parse("2020-08-05 13:14:15").SubDuration("2h30m").ToDateTimeString() // 2020-08-05 10:44:15
-// 一か時間を減らす
+// 1時間減らす
carbon.Parse("2020-08-05 13:14:15").SubHour().ToDateTimeString() // 2020-08-05 12:14:15
-// 三か分钟を追加
+// 3分追加
carbon.Parse("2020-08-05 13:14:15").AddMinutes(3).ToDateTimeString() // 2020-08-05 13:17:15
-// 二か分钟半を追加
+// 2分半追加
carbon.Parse("2020-08-05 13:14:15").AddDuration("2.5m").ToDateTimeString() // 2020-08-05 13:16:45
carbon.Parse("2020-08-05 13:14:15").AddDuration("2m30s").ToDateTimeString() // 2020-08-05 13:16:45
-// 一か分钟を追加
+// 1分追加
carbon.Parse("2020-08-05 13:14:15").AddMinute().ToDateTimeString() // 2020-08-05 13:15:15
-// 三か分钟を減らす
+// 3分減らす
carbon.Parse("2020-08-05 13:14:15").SubMinutes(3).ToDateTimeString() // 2020-08-05 13:11:15
-// 二か分钟半を減らす
+// 2分半減らす
carbon.Parse("2020-08-05 13:14:15").SubDuration("2.5m").ToDateTimeString() // 2020-08-05 13:11:45
carbon.Parse("2020-08-05 13:14:15").SubDuration("2m30s").ToDateTimeString() // 2020-08-05 13:11:45
-// 一か分钟を減らす
+// 1分減らす
carbon.Parse("2020-08-05 13:14:15").SubMinute().ToDateTimeString() // 2020-08-05 13:13:15
-// 三か秒钟を追加
+// 3秒追加
carbon.Parse("2020-08-05 13:14:15").AddSeconds(3).ToDateTimeString() // 2020-08-05 13:14:18
-// 二か秒钟半を追加
+// 2秒半追加
carbon.Parse("2020-08-05 13:14:15").AddDuration("2.5s").ToDateTimeString() // 2020-08-05 13:14:17
-// 一か秒钟を追加
+// 1秒追加
carbon.Parse("2020-08-05 13:14:15").AddSecond().ToDateTimeString() // 2020-08-05 13:14:16
-// 三か秒钟を減らす
+// 3秒減らす
carbon.Parse("2020-08-05 13:14:15").SubSeconds(3).ToDateTimeString() // 2020-08-05 13:14:12
-// 二か秒钟半を減らす
+// 2秒半減らす
carbon.Parse("2020-08-05 13:14:15").SubDuration("2.5s").ToDateTimeString() // 2020-08-05 13:14:12
-// 一か秒钟を減らす
+// 1秒減らす
carbon.Parse("2020-08-05 13:14:15").SubSecond().ToDateTimeString() // 2020-08-05 13:14:14
-// 三かミリ秒を追加
+// 3ミリ秒追加
carbon.Parse("2020-08-05 13:14:15.222222222").AddMilliseconds(3).ToString() // 2020-08-05 13:14:15.225222222 +0800 CST
-// 一かミリ秒を追加
+// 1ミリ秒追加
carbon.Parse("2020-08-05 13:14:15.222222222").AddMillisecond().ToString() // 2020-08-05 13:14:15.223222222 +0800 CST
-// 三かミリ秒を減らす
+// 3ミリ秒減らす
carbon.Parse("2020-08-05 13:14:15.222222222").SubMilliseconds(3).ToString() // 2020-08-05 13:14:15.219222222 +0800 CST
-// 一かミリ秒を減らす
+// 1ミリ秒減らす
carbon.Parse("2020-08-05 13:14:15.222222222").SubMillisecond().ToString() // 2020-08-05 13:14:15.221222222 +0800 CST
-// 三か微妙を追加
+// 3マイクロ秒追加
carbon.Parse("2020-08-05 13:14:15.222222222").AddMicroseconds(3).ToString() // 2020-08-05 13:14:15.222225222 +0800 CST
-// 一か微妙を追加
+// 1マイクロ秒追加
carbon.Parse("2020-08-05 13:14:15.222222222").AddMicrosecond().ToString() // 2020-08-05 13:14:15.222223222 +0800 CST
-// 三か微妙を減らす
+// 3マイクロ秒減らす
carbon.Parse("2020-08-05 13:14:15.222222222").SubMicroseconds(3).ToString() // 2020-08-05 13:14:15.222219222 +0800 CST
-// 一か微妙を減らす
+// 1マイクロ秒減らす
carbon.Parse("2020-08-05 13:14:15.222222222").SubMicrosecond().ToString() // 2020-08-05 13:14:15.222221222 +0800 CST
-// 三かナノ秒を追加
+// 3ナノ秒追加
carbon.Parse("2020-08-05 13:14:15.222222222").AddNanoseconds(3).ToString() // 2020-08-05 13:14:15.222222225 +0800 CST
-// 一かナノ秒を追加
+// 1ナノ秒追加
carbon.Parse("2020-08-05 13:14:15.222222222").AddNanossecond().ToString() // 2020-08-05 13:14:15.222222223 +0800 CST
-// 三かナノ秒を減らす
+// 3ナノ秒減らす
carbon.Parse("2020-08-05 13:14:15.222222222").SubNanosseconds(3).ToString() // 2020-08-05 13:14:15.222222219 +0800 CST
-// 一かナノ秒を減らす
+// 1ナノ秒減らす
carbon.Parse("2020-08-05 13:14:15.222222222").SubNanossecond().ToString() // 2020-08-05 13:14:15.222222221 +0800 CST
```
-##### 时间差異
+##### 時間差分
```go
-// 何年違いますか
+// 年差
carbon.Parse("2021-08-05 13:14:15").DiffInYears(carbon.Parse("2020-08-05 13:14:15")) // -1
-// 何年違いますか(絶対値)
+// 年差(絶対値)
carbon.Parse("2021-08-05 13:14:15").DiffAbsInYears(carbon.Parse("2020-08-05 13:14:15")) // 1
-// 何ヶ月違いますか
+// 月差
carbon.Parse("2020-08-05 13:14:15").DiffInMonths(carbon.Parse("2020-07-05 13:14:15")) // -1
-// 何ヶ月違いますか(絶対値)
+// 月差(絶対値)
carbon.Parse("2020-08-05 13:14:15").DiffAbsInMonths(carbon.Parse("2020-07-05 13:14:15")) // 1
-// 何週間違いますか
+// 週差
carbon.Parse("2020-08-05 13:14:15").DiffInWeeks(carbon.Parse("2020-07-28 13:14:15")) // -1
-// 何週間違いますか(絶対値)
+// 週差(絶対値)
carbon.Parse("2020-08-05 13:14:15").DiffAbsInWeeks(carbon.Parse("2020-07-28 13:14:15")) // 1
-// 何日間違いますか
+// 日差
carbon.Parse("2020-08-05 13:14:15").DiffInDays(carbon.Parse("2020-08-04 13:14:15")) // -1
-// 何日間違いますか(絶対値)
+// 日差(絶対値)
carbon.Parse("2020-08-05 13:14:15").DiffAbsInDays(carbon.Parse("2020-08-04 13:14:15")) // 1
-// 何時間違いますか
+// 時間差
carbon.Parse("2020-08-05 13:14:15").DiffInHours(carbon.Parse("2020-08-05 12:14:15")) // -1
-// 何時間違いますか(絶対値)
+// 時間差(絶対値)
carbon.Parse("2020-08-05 13:14:15").DiffAbsInHours(carbon.Parse("2020-08-05 12:14:15")) // 1
-// 何分違いますか
+// 分差
carbon.Parse("2020-08-05 13:14:15").DiffInMinutes(carbon.Parse("2020-08-05 13:13:15")) // -1
-// 何分違いますか(絶対値)
+// 分差(絶対値)
carbon.Parse("2020-08-05 13:14:15").DiffAbsInMinutes(carbon.Parse("2020-08-05 13:13:15")) // 1
-// 何秒の差がありますか
+// 秒差
carbon.Parse("2020-08-05 13:14:15").DiffInSeconds(carbon.Parse("2020-08-05 13:14:14")) // -1
-// 何秒の差がありますか(絶対値)
+// 秒差(絶対値)
carbon.Parse("2020-08-05 13:14:15").DiffAbsInSeconds(carbon.Parse("2020-08-05 13:14:14")) // 1
-// 時間差を文字列で表す
+// 時間差を文字列で返す
carbon.Now().DiffInString() // just now
carbon.Now().AddYearsNoOverflow(1).DiffInString() // -1 year
carbon.Now().SubYearsNoOverflow(1).DiffInString() // 1 year
-// 時間差を文字列で表す(絶対値)
+// 時間差を文字列で返す(絶対値)
carbon.Now().DiffAbsInString(carbon.Now()) // just now
carbon.Now().AddYearsNoOverflow(1).DiffAbsInString(carbon.Now()) // 1 year
carbon.Now().SubYearsNoOverflow(1).DiffAbsInString(carbon.Now()) // 1 year
-// 相差時間長
+// 継続時間差
now := carbon.Now()
now.DiffInDuration(now).String() // 0s
now.AddHour().DiffInDuration(now).String() // 1h0m0s
now.SubHour().DiffInDuration(now).String() // -1h0m0s
-// 相差時間長(絶対値)
+// 継続時間差(絶対値)
now.DiffAbsInDuration(now).String() // 0s
now.AddHour().DiffAbsInDuration(now).String() // 1h0m0s
now.SubHour().DiffAbsInDuration(now).String() // 1h0m0s
-// 人間に優しい読み取り可能なフォーマットの時間差を取得します
+// 人が読みやすいフォーマットで時間差を取得
carbon.Parse("2020-08-05 13:14:15").DiffForHumans() // just now
carbon.Parse("2019-08-05 13:14:15").DiffForHumans() // 1 year ago
carbon.Parse("2018-08-05 13:14:15").DiffForHumans() // 2 years ago
@@ -563,7 +558,7 @@ carbon.Parse("2018-08-05 13:14:15").DiffForHumans(carbon.Now()) // 1 year after
carbon.Parse("2022-08-05 13:14:15").DiffForHumans(carbon.Now()) // 2 years after
```
-##### 时间极值
+##### 極值
```go
c0 := carbon.Parse("2023-04-01")
@@ -571,7 +566,7 @@ c1 := carbon.Parse("2023-03-28")
c2 := carbon.Parse("2023-04-16")
// 最近のCarbonインスタンスを返す
c0.Closest(c1, c2) // c1
-// 最も遠いCarbonインスタンスを返す
+// 遠いCarbonインスタンスを返す
c0.Farthest(c1, c2) // c2
yesterday := carbon.Yesterday()
@@ -581,12 +576,17 @@ tomorrow := carbon.Tomorrow()
carbon.Max(yesterday, today, tomorrow) // tomorrow
// 最小の Carbon インスタンスを返します
carbon.Min(yesterday, today, tomorrow) // yesterday
+
+// Carbonの最大値を戻す
+carbon.MaxCarbon().ToString() // 9999-12-31 23:59:59.999999999 +0000 UTC
+// Carbonの最小値を戻す
+carbon.MinCarbon().ToString() // -9998-01-01 00:00:00 +0000 UTC
```
-##### 时间比較
+##### 比較
```go
-// 夏時間ですか
+// 夏時間かどうか
carbon.Parse("").IsDST() // false
carbon.Parse("0").IsDST() // false
carbon.Parse("0000-00-00 00:00:00").IsDST() // false
@@ -595,7 +595,7 @@ carbon.Parse("00:00:00").IsDST() // false
carbon.Parse("2023-01-01", "Australia/Brisbane").IsDST() // false
carbon.Parse("2023-01-01", "Australia/Sydney").IsDST() // true
-// ゼロ値の時間ですか
+// ゼロ値の時間かどうか(0001-01-01 00:00:00 +0000 UTC)
carbon.Parse("").IsZero() // true
carbon.Parse("0").IsZero() // true
carbon.Parse("0000-00-00 00:00:00").IsZero() // true
@@ -605,7 +605,7 @@ carbon.Parse("2020-08-05 00:00:00").IsZero() // false
carbon.Parse("2020-08-05").IsZero() // false
carbon.Parse("2020-08-05").SetTimezone("xxx").IsZero() // false
-// 有効時間かどうか
+// 有効な時間かどうか
carbon.Parse("").IsValid() // false
carbon.Parse("0").IsValid() // false
carbon.Parse("0000-00-00 00:00:00").IsValid() // false
@@ -615,7 +615,7 @@ carbon.Parse("2020-08-05 00:00:00").IsValid() // true
carbon.Parse("2020-08-05").IsValid() // true
carbon.Parse("2020-08-05").SetTimezone("xxx").IsValid() // false
-// 無効な時間ですか
+// 無効な時間かどうか
carbon.Parse("").IsInvalid() // true
carbon.Parse("0").IsInvalid() // true
carbon.Parse("0000-00-00 00:00:00").IsInvalid() // true
@@ -625,12 +625,12 @@ carbon.Parse("2020-08-05 00:00:00").IsInvalid() // false
carbon.Parse("2020-08-05").IsInvalid() // false
carbon.Parse("2020-08-05").SetTimezone("xxx").IsInvalid() // true
-// 朝かどうかを判断する
+// 午前かどうか
carbon.Parse("2020-08-05 00:00:00").IsAM() // true
carbon.Parse("2020-08-05 08:00:00").IsAM() // true
carbon.Parse("2020-08-05 12:00:00").IsAM() // false
carbon.Parse("2020-08-05 13:00:00").IsAM() // false
-// 午後かどうかを判断します
+// 午後かどうか
carbon.Parse("2020-08-05 00:00:00").IsPM() // false
carbon.Parse("2020-08-05 08:00:00").IsPM() // false
carbon.Parse("2020-08-05 12:00:00").IsPM() // true
@@ -645,102 +645,102 @@ carbon.Yesterday().IsPast() // true
// 閏年かどうか
carbon.Parse("2020-08-05 13:14:15").IsLeapYear() // true
-// 長年ですか
+// ISO8601で定められたLong Yearかどうか
carbon.Parse("2020-08-05 13:14:15").IsLongYear() // true
-// 一月ですか
+// 1月かどうか
carbon.Parse("2020-08-05 13:14:15").IsJanuary() // false
-// 二月ですか
+// 2月かどうか
carbon.Parse("2020-08-05 13:14:15").IsFebruary() // false
-// 三月ですか
+// 3月かどうか
carbon.Parse("2020-08-05 13:14:15").IsMarch() // false
-// 四月ですか
+// 4月かどうか
carbon.Parse("2020-08-05 13:14:15").IsApril() // false
-// 五月ですか
+// 5月かどうか
carbon.Parse("2020-08-05 13:14:15").IsMay() // false
-// 六月ですか
+// 6月かどうか
carbon.Parse("2020-08-05 13:14:15").IsJune() // false
-// 七月ですか
+// 7月かどうか
carbon.Parse("2020-08-05 13:14:15").IsJuly() // false
-// 八月ですか
+// 8月かどうか
carbon.Parse("2020-08-05 13:14:15").IsAugust() // false
-// 八月ですか
+// 9月かどうか
carbon.Parse("2020-08-05 13:14:15").IsSeptember() // true
-// 十月ですか
+// 10月かどうか
carbon.Parse("2020-08-05 13:14:15").IsOctober() // false
-// 十一月ですか
+// 11月かどうか
carbon.Parse("2020-08-05 13:14:15").IsNovember() // false
-// 十二月ですか
+// 12月かどうか
carbon.Parse("2020-08-05 13:14:15").IsDecember() // false
-// 月曜日ですか
+// 月曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsMonday() // false
-// 火曜日ですか
+// 火曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsTuesday() // true
-// 水曜日ですか
+// 水曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsWednesday() // false
-// 木曜日ですか
+// 木曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsThursday() // false
-// 金曜日ですか
+// 金曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsFriday() // false
-// 土曜日ですか
+// 土曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsSaturday() // false
-// 日曜日ですか
+// 日曜日かどうか
carbon.Parse("2020-08-05 13:14:15").IsSunday() // false
-// 営業日ですか
+// 平日かどうか
carbon.Parse("2020-08-05 13:14:15").IsWeekday() // false
-// 週末ですか
+// 週末かどうか
carbon.Parse("2020-08-05 13:14:15").IsWeekend() // true
-// 昨日ですか
+// 昨日かどうか
carbon.Parse("2020-08-04 13:14:15").IsYesterday() // true
carbon.Parse("2020-08-04 00:00:00").IsYesterday() // true
carbon.Parse("2020-08-04").IsYesterday() // true
-// 今日ですか
+// 今日かどうか
carbon.Parse("2020-08-05 13:14:15").IsToday() // true
carbon.Parse("2020-08-05 00:00:00").IsToday() // true
carbon.Parse("2020-08-05").IsToday() // true
-// 明日ですか
+// 明日かどうか
carbon.Parse("2020-08-06 13:14:15").IsTomorrow() // true
carbon.Parse("2020-08-06 00:00:00").IsTomorrow() // true
carbon.Parse("2020-08-06").IsTomorrow() // true
-// 同じ世紀ですか
+// 同世紀かどうか
carbon.Parse("2020-08-05 13:14:15").IsSameCentury(carbon.Parse("3020-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").IsSameCentury(carbon.Parse("2099-08-05 13:14:15")) // true
-// 同じ時代ですか
+// 同十年紀かどうか
carbon.Parse("2020-08-05 13:14:15").IsSameDecade(carbon.Parse("2030-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").IsSameDecade(carbon.Parse("2120-08-05 13:14:15")) // true
-// 同じ年ですか
+// 同年かどうか
carbon.Parse("2020-08-05 00:00:00").IsSameYear(carbon.Parse("2021-08-05 13:14:15")) // false
carbon.Parse("2020-01-01 00:00:00").IsSameYear(carbon.Parse("2020-12-31 13:14:15")) // true
-// 同じ季節ですか
+// 同四半期かどうか
carbon.Parse("2020-08-05 00:00:00").IsSameQuarter(carbon.Parse("2020-09-05 13:14:15")) // false
carbon.Parse("2020-01-01 00:00:00").IsSameQuarter(carbon.Parse("2021-01-31 13:14:15")) // true
-// 同じ月ですか
+// 同月かどうか
carbon.Parse("2020-01-01 00:00:00").IsSameMonth(carbon.Parse("2021-01-31 13:14:15")) // false
carbon.Parse("2020-01-01 00:00:00").IsSameMonth(carbon.Parse("2020-01-31 13:14:15")) // true
-// 同じ日ですか
+// 同日かどうか
carbon.Parse("2020-08-05 13:14:15").IsSameDay(carbon.Parse("2021-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 00:00:00").IsSameDay(carbon.Parse("2020-08-05 13:14:15")) // true
-// 同じ時間ですか
+// 同時間かどうか
carbon.Parse("2020-08-05 13:14:15").IsSameHour(carbon.Parse("2021-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:00:00").IsSameHour(carbon.Parse("2020-08-05 13:14:15")) // true
-// 同じ分ですか
+// 同分かどうか
carbon.Parse("2020-08-05 13:14:15").IsSameMinute(carbon.Parse("2021-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:00").IsSameMinute(carbon.Parse("2020-08-05 13:14:15")) // true
-// 同じ秒ですか
+// 同秒かどうか
carbon.Parse("2020-08-05 13:14:15").IsSameSecond(carbon.Parse("2021-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").IsSameSecond(carbon.Parse("2020-08-05 13:14:15")) // true
-// 大きいかどうか
+// 超過かどうか
carbon.Parse("2020-08-05 13:14:15").Gt(carbon.Parse("2020-08-04 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Gt(carbon.Parse("2020-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").Compare(">", carbon.Parse("2020-08-04 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare(">", carbon.Parse("2020-08-05 13:14:15")) // false
-// 小さいかどうか
+// 未満かどうか
carbon.Parse("2020-08-05 13:14:15").Lt(carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Lt(carbon.Parse("2020-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").Compare("<", carbon.Parse("2020-08-06 13:14:15")) // true
@@ -752,44 +752,44 @@ carbon.Parse("2020-08-05 13:14:15").Eq(carbon.Parse("2020-08-05 13:14:00")) // f
carbon.Parse("2020-08-05 13:14:15").Compare("=", carbon.Parse("2020-08-05 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare("=", carbon.Parse("2020-08-05 13:14:00")) // false
-// と等しくない
+// と等しくないかどうか
carbon.Parse("2020-08-05 13:14:15").Ne(carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Ne(carbon.Parse("2020-08-05 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").Compare("!=", carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare("<>", carbon.Parse("2020-08-05 13:14:15")) // false
-// 大きいか等しいかどうか
+// 以上かどうか
carbon.Parse("2020-08-05 13:14:15").Gte(carbon.Parse("2020-08-04 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Gte(carbon.Parse("2020-08-05 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare(">=", carbon.Parse("2020-08-04 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare(">=", carbon.Parse("2020-08-05 13:14:15")) // true
-// 小きいか等しいかどうか
+// 以下かどうか
carbon.Parse("2020-08-05 13:14:15").Lte(carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Lte(carbon.Parse("2020-08-05 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare("<=", carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").Compare("<=", carbon.Parse("2020-08-05 13:14:15")) // true
-// 二つの時間の間に(この二つの時間は含まれていません)
+// 二つの Carbon インスタンスの間に含まれているか(開始時間、終了時間を含まない)
carbon.Parse("2020-08-05 13:14:15").Between(carbon.Parse("2020-08-05 13:14:15"), carbon.Parse("2020-08-06 13:14:15")) // false
carbon.Parse("2020-08-05 13:14:15").Between(carbon.Parse("2020-08-04 13:14:15"), carbon.Parse("2020-08-06 13:14:15")) // true
-// 二つの時間の間に(開始時間も含めて)
+// 二つの Carbon インスタンスの間に含まれているか(開始時間を含む)
carbon.Parse("2020-08-05 13:14:15").BetweenIncludedStart(carbon.Parse("2020-08-05 13:14:15"), carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").BetweenIncludedStart(carbon.Parse("2020-08-04 13:14:15"), carbon.Parse("2020-08-06 13:14:15")) // true
-// 二つの時間の間に(終了時間も含めて)
+// 二つの Carbon インスタンスの間に含まれているか(終了時間を含む)
carbon.Parse("2020-08-05 13:14:15").BetweenIncludedEnd(carbon.Parse("2020-08-04 13:14:15"), carbon.Parse("2020-08-05 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").BetweenIncludedEnd(carbon.Parse("2020-08-04 13:14:15"), carbon.Parse("2020-08-06 13:14:15")) // true
-// 二つの時間の間に(この二つの時間を含めて)
+// 二つの Carbon インスタンスの間に含まれているか(開始時間、終了時間を含む)
carbon.Parse("2020-08-05 13:14:15").BetweenIncludedBoth(carbon.Parse("2020-08-05 13:14:15"), carbon.Parse("2020-08-06 13:14:15")) // true
carbon.Parse("2020-08-05 13:14:15").BetweenIncludedBoth(carbon.Parse("2020-08-04 13:14:15"), carbon.Parse("2020-08-05 13:14:15")) // true
```
> 長年の定義については、読んでください https://en.wikipedia.org/wiki/ISO_8601#Week_dates
-##### 时间設定
+##### 設定
```go
// タイムゾーンを設定
@@ -803,7 +803,7 @@ carbon.SetLocation(utc).Now().ToDateTimeString() // 2022-06-28 09:25:38
tokyo, _ := time.LoadLocation(carbon.Tokyo)
carbon.SetLocation(tokyo).Now().ToDateTimeString() // 2022-06-28 18:25:38
-// ロケール設定
+// ロケールを設定
carbon.Parse("2020-07-05 13:14:15").SetLocale("en").DiffForHumans()) // 1 month ago
carbon.Parse("2020-07-05 13:14:15").SetLocale("jp").DiffForHumans() // 1 ヶ月前
@@ -889,27 +889,27 @@ carbon.Parse("2020-08-05 13:14:15").SetNanosecond(100000000).Nanosecond() // 100
carbon.Parse("2020-08-05 13:14:15").SetNanosecond(999999999).Nanosecond() // 999999999
```
-##### 时间取得
+##### 取得
```go
-// 本年の総日数を取得
+// 年の総日数を取得
carbon.Parse("2019-08-05 13:14:15").DaysInYear() // 365
carbon.Parse("2020-08-05 13:14:15").DaysInYear() // 366
-// 今月の総日数を取得
+// 月の総日数を取得
carbon.Parse("2020-02-01 13:14:15").DaysInMonth() // 29
carbon.Parse("2020-04-01 13:14:15").DaysInMonth() // 30
carbon.Parse("2020-08-01 13:14:15").DaysInMonth() // 31
-// 本年の第数日を取得
+// 年間積算日を取得
carbon.Parse("2020-08-05 13:14:15").DayOfYear() // 218
-// 本年の第数週を取得
+// 本年の何週目かを取得
carbon.Parse("2019-12-31 13:14:15").WeekOfYear() // 1
carbon.Parse("2020-08-05 13:14:15").WeekOfYear() // 32
-// 今月の何日目(1から)を取得
+// 今月の何日目(1から)かを取得
carbon.Parse("2020-08-05 13:14:15").DayOfMonth() // 5
-// 今月の何週目(1から)を取得
+// 今月の何週目かを取得
carbon.Parse("2020-08-05 13:14:15").WeekOfMonth() // 1
-// 今月の何週目(1から)を取得
+// 今週の何日目かを取得(1が月曜日)
carbon.Parse("2020-08-05 13:14:15").DayOfWeek() // 3
// 現在の年月日時分秒を取得
@@ -941,7 +941,7 @@ carbon.Parse("2020-08-05 13:14:15.999999999").TimeNano() // 13,14,15,999999999
// 現在の世紀を取得
carbon.Parse("2020-08-05 13:14:15").Century() // 21
-// 現在の年代を取得
+// 現在の十年紀を取得
carbon.Parse("2019-08-05 13:14:15").Decade() // 10
carbon.Parse("2021-08-05 13:14:15").Decade() // 20
// 現在の年を取得
@@ -986,7 +986,7 @@ carbon.SetTimezone(carbon.Tokyo).Timezone() // JST
carbon.SetTimezone(carbon.PRC).Location() // PRC
carbon.SetTimezone(carbon.Tokyo).Location() // Asia/Tokyo
-// UTCタイムゾーンからのオフセットを取得,単位秒
+// UTCタイムゾーンオフセットの秒を取得
carbon.SetTimezone(carbon.PRC).Offset() // 28800
carbon.SetTimezone(carbon.Tokyo).Offset() // 32400
@@ -997,155 +997,155 @@ carbon.Now().SetLocale("zh-CN").Locale() // zh-CN
// 星座を取得
carbon.Now().Constellation() // Leo
carbon.Now().SetLocale("en").Constellation() // Leo
-carbon.Now().SetLocale("jp").Constellation() // 獅子座
+carbon.Now().SetLocale("jp").Constellation() // しし座
// 季節を取得
carbon.Now().Season() // Summer
carbon.Now().SetLocale("en").Season() // Summer
-carbon.Now().SetLocale("jp").Season() // 夏か
+carbon.Now().SetLocale("jp").Season() // 夏
// 年齢を取得
carbon.Parse("2002-01-01 13:14:15").Age() // 17
carbon.Parse("2002-12-31 13:14:15").Age() // 18
```
-##### 时间出力
+##### 出力
```go
-// 日期时间文字列を出力
+// datetimeを文字列出力
carbon.Parse("2020-08-05 13:14:15").ToDateTimeString() // 2020-08-05 13:14:15
-// 日期时间文字列を出力,ミリ秒を含む
+// ミリ秒を含むdatetimeを文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToDateTimeMilliString() // 2020-08-05 13:14:15.999
-// 日期时间文字列を出力,マイクロ秒を含む
+// マイクロ秒を含むdatetimeを文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToDateTimeMicroString() // 2020-08-05 13:14:15.999999
-// 日期时间文字列を出力,ナノ秒を含む
+// ナノ秒を含むdatetimeを文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToDateTimeNanoString() // 2020-08-05 13:14:15.999999999
-// 略語日期时间文字列を出力
+// datetimeを略語形式の文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToShortDateTimeString() // 20200805131415
-// 略語日期时间文字列を出力,ミリ秒を含む
+// ミリ秒を含むdatetimeを略語形式の文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToShortDateTimeMilliString() // 20200805131415.999
-// 略語日期时间文字列を出力,マイクロ秒を含む
+// マイクロ秒を含むdatetimeを略語形式の文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToShortDateTimeMicroString() // 20200805131415.999999
-// 略語日期时间文字列を出力,ナノ秒を含む
+// ナノ秒を含むdatetimeを略語形式の文字列出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToShortDateTimeNanoString() // 20200805131415.999999999
-// 日期文字列を出力
+// dateを文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToDateString() // 2020-08-05
-// 日期文字列を出力,ミリ秒を含む
+// ミリ秒を含むdateを文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToDateMilliString() // 2020-08-05.999
-// 日期文字列を出力,マイクロ秒を含む
+// マイクロ秒を含むdateを文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToDateMicroString() // 2020-08-05.999999
-// 日期文字列を出力,ナノ秒を含む
+// ナノ秒を含むdateを文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToDateNanoString() // 2020-08-05.999999999
-// 略語日期文字列を出力
+// dateを略語形式の文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortDateString() // 20200805
-// 输出简写日期字符串,ミリ秒を含む
+// ミリ秒を含むdateを略語形式の文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortDateMilliString() // 20200805.999
-// 输出简写日期字符串,マイクロ秒を含む
+// マイクロ秒を含むdateを略語形式の文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortDateMicroString() // 20200805.999999
-// 输出简写日期字符串,ナノ秒を含む
+// ナノ秒を含むdateを略語形式の文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortDateNanoString() // 20200805.999999999
-// 時間文字列を出力
+// 時間を文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToTimeString() // 13:14:15
-// 時間文字列を出力,ミリ秒を含む
+// ミリ秒を含む時間を文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToTimeMilliString() // 13:14:15.999
-// 時間文字列を出力,マイクロ秒を含む
+// マイクロ秒を含む時間を文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToTimeMicroString() // 13:14:15.999999
-// 時間文字列を出力,ナノ秒を含む
+// ナノ秒を含む時間を文字列出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToTimeNanoString() // 13:14:15.999999999
-// 略語時間文字列を出力
+// 時間を略語形式の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortTimeString() // 131415
-// 略語時間文字列を出力,ミリ秒を含む
+// ミリ秒を含む時間を略語形式の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortTimeMilliString() // 131415.999
-// 略語時間文字列を出力,マイクロ秒を含む
+// マイクロ秒を含む時間を略語形式の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortTimeMicroString() // 131415.999999
-// 略語時間文字列を出力,ナノ秒を含む
+// ナノ秒を含む時間を略語形式の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToShortTimeNanoString() // 131415.999999999
-// Ansic フォーマット文字列を出力
+// Ansic フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToAnsicString() // Wed Aug 5 13:14:15 2020
-// Atom フォーマット文字列を出力
+// Atom フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToAtomString() // 2020-08-05T13:14:15+08:00
-// UnixDate フォーマット文字列を出力
+// UnixDate フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToUnixDateString() // Wed Aug 5 13:14:15 CST 2020
-// RubyDate フォーマット文字列を出力
+// RubyDate フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRubyDateString() // Wed Aug 05 13:14:15 +0800 2020
-// Kitchen フォーマット文字列を出力
+// Kitchen フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToKitchenString() // 1:14PM
-// Cookie フォーマット文字列を出力
+// Cookie フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToCookieString() // Wednesday, 05-Aug-2020 13:14:15 CST
-// DayDateTime フォーマット文字列を出力
+// DayDateTime フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToDayDateTimeString() // Wed, Aug 5, 2020 1:14 PM
-// RSS フォーマット文字列を出力
+// RSS フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRssString() // Wed, 05 Aug 2020 13:14:15 +0800
-// W3C フォーマット文字列を出力
+// W3C フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToW3cString() // 2020-08-05T13:14:15+08:00
-// ISO8601 フォーマット文字列を出力
+// ISO8601 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601String() // 2020-08-05T13:14:15+08:00
-// ISO8601Milli フォーマット文字列を出力
+// ISO8601Milli フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601MilliString() // 2020-08-05T13:14:15.999+08:00
-// ISO8601Micro フォーマット文字列を出力
+// ISO8601Micro フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601MicroString() // 2020-08-05T13:14:15.999999+08:00
-// ISO8601Nano フォーマット文字列を出力
+// ISO8601Nano フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601NanoString() // 2020-08-05T13:14:15.999999999+08:00
-// ISO8601Zulu フォーマット文字列を出力
+// ISO8601Zulu フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601ZuluString() // 2020-08-05T13:14:15Z
-// ISO8601ZuluMilli フォーマット文字列を出力
+// ISO8601ZuluMilli フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601ZuluMilliString() // 2020-08-05T13:14:15.999Z
-// ISO8601ZuluMicro フォーマット文字列を出力
+// ISO8601ZuluMicro フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601ZuluMicroString() // 2020-08-05T13:14:15.999999Z
-// ISO8601ZuluNano フォーマット文字列を出力
+// ISO8601ZuluNano フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15.999999999").ToIso8601ZuluNanoString() // 2020-08-05T13:14:15.999999999Z
-// RFC822 フォーマット文字列を出力
+// RFC822 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc822String() // 05 Aug 20 13:14 CST
-// RFC822Z フォーマット文字列を出力
+// RFC822Z フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc822zString() // 05 Aug 20 13:14 +0800
-// RFC850 フォーマット文字列を出力
+// RFC850 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc850String() // Wednesday, 05-Aug-20 13:14:15 CST
-// RFC1036 フォーマット文字列を出力
+// RFC1036 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc1036String() // Wed, 05 Aug 20 13:14:15 +0800
-// RFC1123 フォーマット文字列を出力
+// RFC1123 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc1123String() // Wed, 05 Aug 2020 13:14:15 CST
-// RFC1123Z フォーマット文字列を出力
+// RFC1123Z フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc1123zString() // Wed, 05 Aug 2020 13:14:15 +0800
-// RFC2822 フォーマット文字列を出力
+// RFC2822 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc2822String() // Wed, 05 Aug 2020 13:14:15 +0800
-// RFC7231 フォーマット文字列を出力
+// RFC7231 フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToRfc7231String() // Wed, 05 Aug 2020 13:14:15 GMT
-// RFC3339 フォーマット文字列を出力
+// RFC3339 フォーマット文字列の出力
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToRfc3339String() // 2020-08-05T13:14:15+08:00
-// RFC3339 フォーマット文字列を出力,ミリ秒を含む
+// RFC3339 フォーマット文字列の出力(ミリ秒を含む)
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToRfc3339MilliString() // 2020-08-05T13:14:15.999+08:00
-// RFC3339 フォーマット文字列を出力,マイクロ秒を含む
+// RFC3339 フォーマット文字列の出力(マイクロ秒を含む)
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToRfc3339MicroString() // 2020-08-05T13:14:15.999999+08:00
-// RFC3339 フォーマット文字列を出力,ナノ秒を含む
+// RFC3339 フォーマット文字列の出力(ナノ秒を含む)
carbon.Parse("2020-08-05T13:14:15.999999999+08:00").ToRfc3339NanoString() // 2020-08-05T13:14:15.999999999+08:00
-// 日付時間文字列を出力
+// 日付時間文字列の出力
fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15")) // 2020-08-05 13:14:15
-// "2006-01-02 15:04:05.999999999 -0700 MST" フォーマット文字列を出力
+// "2006-01-02 15:04:05.999999999 -0700 MST" フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToString() // 2020-08-05 13:14:15.999999 +0800 CST
-// "Jan 2, 2006" フォーマット文字列を出力
+// "Jan 2, 2006" フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToFormattedDateString() // Aug 5, 2020
-// "Mon, Jan 2, 2006" フォーマット文字列を出力
+// "Mon, Jan 2, 2006" フォーマット文字列の出力
carbon.Parse("2020-08-05 13:14:15").ToFormattedDayDateString() // Wed, Aug 5, 2020
-// レイアウトを指定する文字列を出力
+// レイアウトを指定する文字列の出力
carbon.Parse("2020-08-05 13:14:15").Layout(carbon.ISO8601Layout) // 2020-08-05T13:14:15+08:00
carbon.Parse("2020-08-05 13:14:15").Layout("20060102150405") // 20200805131415
carbon.Parse("2020-08-05 13:14:15").Layout("2006年01月02日 15时04分05秒") // 2020年08月05日 13时14分15秒
carbon.Parse("2020-08-05 13:14:15").Layout("It is 2006-01-02 15:04:05") // It is 2020-08-05 13:14:15
-// 指定されたフォーマットの文字列を出力
+// 指定されたフォーマットの文字列の出力
carbon.Parse("2020-08-05 13:14:15").Format("YmdHis") // 20200805131415
carbon.Parse("2020-08-05 13:14:15").Format("Y年m月d日 H时i分s秒") // 2020年08月05日 13时14分15秒
carbon.Parse("2020-08-05 13:14:15").Format("l jS \\o\\f F Y h:i:s A") // Wednesday 5th of August 2020 01:14:15 PM
@@ -1160,29 +1160,29 @@ carbon.Parse("2020-08-05 13:14:15").Format("\\I\\t \\i\\s Y-m-d H:i:s") // It is
// 星座を取得
carbon.Parse("2020-08-05 13:14:15").Constellation() // Leo
-// 牡羊座ですか
+// おひつじ座かどうか
carbon.Parse("2020-08-05 13:14:15").IsAries() // false
-// おうし座ですか
+// おうし座かどうか
carbon.Parse("2020-08-05 13:14:15").IsTaurus() // false
-// 双子座ですか
+// ふたご座かどうか
carbon.Parse("2020-08-05 13:14:15").IsGemini() // false
-// かに座ですか
+// かに座かどうか
carbon.Parse("2020-08-05 13:14:15").IsCancer() // false
-// 獅子座ですか
+// しし座かどうか
carbon.Parse("2020-08-05 13:14:15").IsLeo() // true
-// おとめ座ですか
+// おとめ座かどうか
carbon.Parse("2020-08-05 13:14:15").IsVirgo() // false
-// 天秤座ですか
+// てんびん座かどうか
carbon.Parse("2020-08-05 13:14:15").IsLibra() // false
-// さそり座ですか
+// さそり座かどうか
carbon.Parse("2020-08-05 13:14:15").IsScorpio() // false
-// 射手座ですか
+// いて座かどうか
carbon.Parse("2020-08-05 13:14:15").IsSagittarius() // false
-// 山羊座ですか
+// やぎ座かどうか
carbon.Parse("2020-08-05 13:14:15").IsCapricorn() // false
-// 水瓶座ですか
+// みずがめ座かどうか
carbon.Parse("2020-08-05 13:14:15").IsAquarius() // false
-// 魚座ですか
+// うお座かどうか
carbon.Parse("2020-08-05 13:14:15").IsPisces() // false
```
@@ -1191,12 +1191,12 @@ carbon.Parse("2020-08-05 13:14:15").IsPisces() // false
> 気象区分によると、3-5月は春で、6-8月は夏で、9-11月は秋で、12-2月は冬です
```go
-// シーズンを取得
+// 季節を取得
carbon.Parse("2020-08-05 13:14:15").Season() // Summer
-// この季節の始まり
+// この季節の開始日
carbon.Parse("2020-08-05 13:14:15").StartOfSeason().ToDateTimeString() // 2020-06-01 00:00:00
-// この季節の終わり
+// この季節の最終日
carbon.Parse("2020-08-05 13:14:15").EndOfSeason().ToDateTimeString() // 2020-08-31 23:59:59
// 春かどうか
@@ -1211,219 +1211,162 @@ carbon.Parse("2020-08-05 13:14:15").IsWinter() // false
##### JSON
-###### シナリオ 1: すべての時刻フィールドが同じ形式である
-```go
-carbon.SetDefault(carbon.Default{
- Layout: carbon.DateTimeLayout,
-})
-
-type Person struct {
- Name string `json:"name"`
- Age int `json:"age"`
-
- Field1 carbon.Carbon `json:"field1"`
- Field2 carbon.Carbon `json:"field2"`
- Field3 carbon.Carbon `json:"field3"`
- Field4 carbon.Carbon `json:"field4"`
-
- Field5 carbon.Carbon `json:"field5"`
- Field6 carbon.Carbon `json:"field6"`
- Field7 carbon.Carbon `json:"field7"`
- Field8 carbon.Carbon `json:"field8"`
-}
-
-now := carbon.Parse("2020-08-05 13:14:15", carbon.PRC)
-person := Person {
- Name: "gouguoyin",
- Age: 18,
-
- Field1: now,
- Field2: now,
- Field3: now,
- Field4: now,
- Field5: now,
- Field6: now,
- Field7: now,
- Field8: now,
-}
-
-data, marshalErr := json.Marshal(person)
-if marshalErr != nil {
- // エラー処理...
- log.Fatal(marshalErr)
-}
-fmt.Printf("%s", data)
-// 出力
-{
- "name": "gouguoyin",
- "age": 18,
- "field1": "2020-08-05 13:14:15",
- "field2": "2020-08-05 13:14:15",
- "field3": "2020-08-05 13:14:15",
- "field4": "2020-08-05 13:14:15",
- "field5": "2020-08-05 13:14:15",
- "field6": "2020-08-05 13:14:15",
- "field7": "2020-08-05 13:14:15",
- "field8": "2020-08-05 13:14:15"
-}
-
-unmarshalErr := json.Unmarshal(data, &person)
-if unmarshalErr != nil {
- // エラー処理...
- log.Fatal(unmarshalErr)
-}
-
-fmt.Printf("%s", person.Field1) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field2) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field3) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field4) // 2020-08-05 13:14:15
-
-fmt.Printf("%s", person.Field5) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field6) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field7) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field8) // 2020-08-05 13:14:15
-```
-
-###### シナリオ 2: 異なる時刻フィールドは異なる形式を持つ
-
-> サポートされているすべての type 値については、ここをクリックしてご覧ください。「carbon」タグが設定されていない場合、デフォルトは「layout:2006-01-02 15:04:05」です。「tz」タグが設定されていない場合、デフォルトは「Local」です。
-
```go
type Person struct {
Name string `json:"name"`
- Age int `json:"age"`
-
- Field1 carbon.Carbon `json:"field1"`
-
- Field2 carbon.Carbon `json:"field2" carbon:"type:date" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"type:time" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"type:dateTime" tz:"PRC"`
- // または
- Field2 carbon.Carbon `json:"field2" carbon:"layout:2006-01-02" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"layout:15:04:05" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
- // または
- Field2 carbon.Carbon `json:"field2" carbon:"format:Y-m-d" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"format:H:i:s" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
-
- Field5 carbon.Carbon `json:"field5" carbon:"type:timestamp" tz:"PRC"`
- Field6 carbon.Carbon `json:"field6" carbon:"type:timestampMilli" tz:"PRC"`
- Field7 carbon.Carbon `json:"field7" carbon:"type:timestampMicro" tz:"PRC"`
- Field8 carbon.Carbon `json:"field8" carbon:"type:timestampNano" tz:"PRC"`
+ Age int `json:"age"`
+ Birthday0 carbon.Carbon `json:"birthday0"`
+ Birthday1 carbon.DateTime `json:"birthday1"`
+ Birthday2 carbon.DateTimeMilli `json:"birthday2"`
+ Birthday3 carbon.DateTimeMicro `json:"birthday3"`
+ Birthday4 carbon.DateTimeNano `json:"birthday4"`
+ GraduatedAt1 carbon.Date `json:"graduated_at1"`
+ GraduatedAt2 carbon.DateMilli `json:"graduated_at2"`
+ GraduatedAt3 carbon.DateMicro `json:"graduated_at3"`
+ GraduatedAt4 carbon.DateNano `json:"graduated_at4"`
+ OperatedAt1 carbon.Time `json:"operated_at1"`
+ OperatedAt2 carbon.TimeMilli `json:"operated_at2"`
+ OperatedAt3 carbon.TimeMicro `json:"operated_at3"`
+ OperatedAt4 carbon.TimeNano `json:"operated_at4"`
+ CreatedAt1 carbon.Timestamp `json:"created_at1"`
+ CreatedAt2 carbon.TimestampMilli `json:"created_at2"`
+ CreatedAt3 carbon.TimestampMicro `json:"created_at3"`
+ CreatedAt4 carbon.TimestampNano `json:"created_at4"`
}
-now := Parse("2020-08-05 13:14:15", carbon.PRC)
person := Person {
- Name: "gouguoyin",
- Age: 18,
-
- Field1: now,
- Field2: now,
- Field3: now,
- Field4: now,
- Field5: now,
- Field6: now,
- Field7: now,
- Field8: now,
+ Name: "gouguoyin",
+ Age: 18,
+ Birthday0: carbon.Now().SubYears(18),
+ Birthday1: carbon.NewDateTime(carbon.Now().SubYears(18)),
+ Birthday2: carbon.NewDateTimeMilli(carbon.Now().SubYears(18)),
+ Birthday3: carbon.NewDateTimeMicro(carbon.Now().SubYears(18)),
+ Birthday4: carbon.NewDateTimeNano(carbon.Now().SubYears(18)),
+ GraduatedAt1: carbon.NewDate(carbon.Now()),
+ GraduatedAt2: carbon.NewDateMilli(carbon.Now()),
+ GraduatedAt3: carbon.NewDateMicro(carbon.Now()),
+ GraduatedAt4: carbon.NewDateNano(carbon.Now()),
+ OperatedAt1: carbon.NewTime(carbon.Now()),
+ OperatedAt2: carbon.NewTimeMilli(carbon.Now()),
+ OperatedAt3: carbon.NewTimeMicro(carbon.Now()),
+ OperatedAt4: carbon.NewTimeNano(carbon.Now()),
+ CreatedAt1: carbon.NewTimestamp(carbon.Now()),
+ CreatedAt2: carbon.NewTimestampMilli(carbon.Now()),
+ CreatedAt3: carbon.NewTimestampMicro(carbon.Now()),
+ CreatedAt4: carbon.NewTimestampNano(carbon.Now()),
}
-loadErr := carbon.LoadTag(&person)
-if loadErr != nil {
+data, err := json.Marshal(&person)
+if err != nil {
// エラー処理...
- log.Fatal(loadErr)
-}
-data, marshalErr := json.Marshal(person)
-if marshalErr != nil {
- // エラー処理...
- log.Fatal(marshalErr)
+ log.Fatal(err)
}
fmt.Printf("%s", data)
// 出力
{
"name": "gouguoyin",
"age": 18,
- "field1": "2020-08-05 13:14:15",
- "field2": "2020-08-05",
- "field3": "13:14:15",
- "field4": "2020-08-05 13:14:15",
- "field5": 1596604455,
- "field6": 1596604455999,
- "field7": 1596604455999999,
- "field8": 1596604455999999999
+ "birthday0": "2003-07-16 13:14:15",
+ "birthday1": "2003-07-16 13:14:15",
+ "birthday2": "2003-07-16 13:14:15.999",
+ "birthday3": "2003-07-16 13:14:15.999999",
+ "birthday4": "2003-07-16 13:14:15.999999999",
+ "graduated_at1": "2020-08-05",
+ "graduated_at2": "2020-08-05.999",
+ "graduated_at3": "2020-08-05.999999",
+ "graduated_at4": "2020-08-05.999999999",
+ "operated_at1": "13:14:15",
+ "operated_at2": "13:14:15.999",
+ "operated_at3": "13:14:15.999999",
+ "operated_at4": "13:14:15.999999999",
+ "created_at1": 1596604455,
+ "created_at2": 1596604455999,
+ "created_at3": 1596604455999999,
+ "created_at4": 1596604455999999999
}
-var person Person
-
-loadErr := carbon.LoadTag(&person)
-if loadErr != nil {
+err := json.Unmarshal([]byte(data), &person)
+if err != nil {
// エラー処理...
- log.Fatal(loadErr)
+ log.Fatal(err)
}
-unmarshalErr := json.Unmarshal(data, &person)
-if unmarshalErr != nil {
- // エラー処理...
- log.Fatal(unmarshalErr)
-}
-
-fmt.Printf("%s", person.Field1) // 2002-08-05 13:14:15
-fmt.Printf("%s", person.Field2) // 2020-08-05
-fmt.Printf("%s", person.Field3) // 13:14:15
-fmt.Printf("%s", person.Field4) // 2002-08-05 13:14:15
-
-fmt.Printf("%d", person.Field5) // 1596604455
-fmt.Printf("%d", person.Field6) // 1596604455999
-fmt.Printf("%d", person.Field7) // 1596604455999999
-fmt.Printf("%d", person.Field8) // 1596604455999999999
-
+person.Birthday0.String() // 2003-07-16 13:14:15
+person.Birthday1.String() // 2003-07-16 13:14:15
+person.Birthday2.String() // 2003-07-16 13:14:15.999
+person.Birthday3.String() // 2003-07-16 13:14:15.999999
+person.Birthday4.String() // 2003-07-16 13:14:15.999999999
+
+person.GraduatedAt1.String() // 2020-08-05
+person.GraduatedAt2.String() // 2020-08-05.999
+person.GraduatedAt3.String() // 2020-08-05.999999
+person.GraduatedAt4.String() // 2020-08-05.999999999
+
+person.OperatedAt1.String() // 13:14:15
+person.OperatedAt2.String() // 13:14:15.999
+person.OperatedAt3.String() // 13:14:15.999999
+person.OperatedAt4.String() // 13:14:15.999999999
+
+person.CreatedAt1.String() // "1596604455"
+person.CreatedAt2.String() // "1596604455999"
+person.CreatedAt3.String() // "1596604455999999"
+person.CreatedAt4.String() // "1596604455999999999"
+
+person.CreatedAt1.Int64() // 1596604455
+person.CreatedAt2.Int64() // 1596604455999
+person.CreatedAt3.Int64() // 1596604455999999
+person.CreatedAt4.Int64() // 1596604455999999999
```
-##### カレンダ#カレンダ#
+##### カレンダー
-現在サポートされているカレンダーは
+現在サポートされているカレンダー
* [儒略の日/簡略化儒略の日](./calendar/julian/README.jp.md "儒略日/简化儒略日")
* [中国の旧暦](./calendar/lunar/README.jp.md "中国の旧暦")
* [ペルシャ暦/イラン暦](./calendar/persian/README.jp.md "ペルシャ暦/イラン暦")
-##### 国際化
+##### i18n
現在サポートされている言語
-* [简体中国語(zh-CN)](./lang/zh-CN.json "简体中国語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") から翻訳されます
-* [繁体中国語(zh-TW)](./lang/zh-TW.json "繁体中国語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") から翻訳されます
-* [英語(en)](./lang/en.json "英語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") から翻訳されます
-* [日本語(jp)](./lang/jp.json "日本語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") から翻訳されます
-* [韓国語(kr)](./lang/kr.json "韓国語"):[benzammour](https://github.com/benzammour "benzammour") から翻訳されます
-* [ドイツ語(de)](./lang/de.json "ドイツ語"):[benzammour](https://github.com/benzammour "benzammour") から翻訳されます
-* [スペイン語(es)](./lang/es.json "スペイン語"):[hgisinger](https://github.com/hgisinger "hgisinger") から翻訳されます
-* [トルコ語(tr)](./lang/tr.json "トルコ語"):[emresenyuva](https://github.com/emresenyuva "emresenyuva") から翻訳されます
-* [ポルトガル語(pt)](./lang/pt.json "ポルトガル語"):[felipear89](https://github.com/felipear89 "felipear89") から翻訳されます
-* [ロシア語(ru)](./lang/ru.json "ロシア語"):[zemlyak](https://github.com/zemlyak "zemlyak") から翻訳されます
-* [ウクライナ語(uk)](./lang/uk.json "ウクライナ語"):[open-git](https://github.com/open-git "open-git") から翻訳されます
-* [ルーマニア語(ro)](./lang/ro.json "ルーマニア語"): [DrOctavius](https://github.com/DrOctavius "DrOctavius") から翻訳されます
-* [インドネシア語(id)](./lang/id.json "インドネシア語"): [justpoypoy](https://github.com/justpoypoy "justpoypoy") から翻訳されます
-* [イタリア語(it)](./lang/it.json "イタリア語"): [nicoloHevelop](https://github.com/hollowaykeanho "nicoloHevelop") から翻訳されます
-* [マレーシアバハマ語(ms-MY)](./lang/ms-MY.json "マレーシアバハマ語"): [hollowaykeanho](https://github.com/hollowaykeanho "hollowaykeanho") から翻訳されます
-* [フランス語(fr)](./lang/fr.json "フランス語"): [hollowaykeanho](https://github.com/hollowaykeanho "hollowaykeanho") から翻訳されます
-* [タイ語(th)](./lang/th.json "タイ語"): [izcream](https://github.com/izcream "izcream") から翻訳されます
-* [スウェーデン語(se)](./lang/se.json "スウェーデン語"): [jwanglof](https://github.com/jwanglof "jwanglof") から翻訳されます
-* [ペルシア語(fa)](./lang/fa.json "ペルシア語"): [Iranian](https://github.com/Iranian "Iranian") から翻訳されます
-* [ポーランド語(nl)](./lang/nl.json "ポーランド語"): [RemcoE33](https://github.com/RemcoE33 "RemcoE33") から翻訳されます
-* [ベトナム語(vi)](./lang/vi.json "ベトナム語"): [culy247](https://github.com/culy247 "culy247") から翻訳されます
-* [ヒンディー語(hi)](./lang/hi.json "ヒンディー語"): [chauhan17nitin](https://github.com/chauhan17nitin "chauhan17nitin") から翻訳されます
-* [ポーランド語(pl)](./lang/pl.json "ポーランド語"): [gouguoyin](https://github.com/gouguoyin "gouguoyin") から翻訳されます
+* [简体中国語(zh-CN)](./lang/zh-CN.json "简体中国語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") に翻訳
+* [繁体中国語(zh-TW)](./lang/zh-TW.json "繁体中国語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") に翻訳
+* [英語(en)](./lang/en.json "英語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") に翻訳
+* [日本語(jp)](./lang/jp.json "日本語"):[gouguoyin](https://github.com/gouguoyin "gouguoyin") に翻訳
+* [韓国語(kr)](./lang/kr.json "韓国語"):[benzammour](https://github.com/benzammour "benzammour") に翻訳
+* [ドイツ語(de)](./lang/de.json "ドイツ語"):[benzammour](https://github.com/benzammour "benzammour") に翻訳
+* [スペイン語(es)](./lang/es.json "スペイン語"):[hgisinger](https://github.com/hgisinger "hgisinger") に翻訳
+* [トルコ語(tr)](./lang/tr.json "トルコ語"):[emresenyuva](https://github.com/emresenyuva "emresenyuva") に翻訳
+* [ポルトガル語(pt)](./lang/pt.json "ポルトガル語"):[felipear89](https://github.com/felipear89 "felipear89") に翻訳
+* [ロシア語(ru)](./lang/ru.json "ロシア語"):[zemlyak](https://github.com/zemlyak "zemlyak") に翻訳
+* [ウクライナ語(uk)](./lang/uk.json "ウクライナ語"):[open-git](https://github.com/open-git "open-git") に翻訳
+* [ルーマニア語(ro)](./lang/ro.json "ルーマニア語"): [DrOctavius](https://github.com/DrOctavius "DrOctavius") に翻訳
+* [インドネシア語(id)](./lang/id.json "インドネシア語"): [justpoypoy](https://github.com/justpoypoy "justpoypoy") に翻訳
+* [イタリア語(it)](./lang/it.json "イタリア語"): [nicoloHevelop](https://github.com/hollowaykeanho "nicoloHevelop") に翻訳
+* [マレーシアバハマ語(ms-MY)](./lang/ms-MY.json "マレーシアバハマ語"): [hollowaykeanho](https://github.com/hollowaykeanho "hollowaykeanho") に翻訳
+* [フランス語(fr)](./lang/fr.json "フランス語"): [hollowaykeanho](https://github.com/hollowaykeanho "hollowaykeanho") に翻訳
+* [タイ語(th)](./lang/th.json "タイ語"): [izcream](https://github.com/izcream "izcream") に翻訳
+* [スウェーデン語(se)](./lang/se.json "スウェーデン語"): [jwanglof](https://github.com/jwanglof "jwanglof") に翻訳
+* [ペルシア語(fa)](./lang/fa.json "ペルシア語"): [Iranian](https://github.com/Iranian "Iranian") に翻訳
+* [ポーランド語(nl)](./lang/nl.json "ポーランド語"): [RemcoE33](https://github.com/RemcoE33 "RemcoE33") に翻訳
+* [ベトナム語(vi)](./lang/vi.json "ベトナム語"): [culy247](https://github.com/culy247 "culy247") に翻訳
+* [ヒンディー語(hi)](./lang/hi.json "ヒンディー語"): [chauhan17nitin](https://github.com/chauhan17nitin "chauhan17nitin") に翻訳
+* [ポーランド語(pl)](./lang/pl.json "ポーランド語"): [gouguoyin](https://github.com/gouguoyin "gouguoyin") に翻訳
+* [ブルガリア語(bg)](./lang/bg.json "ブルガリア語"): [yuksbg](https://github.com/yuksbg "yuksbg") に翻訳
+* [アラビア語(ar)](./lang/ar.json "アラビア語"): [zumoshi](https://github.com/zumoshi "zumoshi") に翻訳
+* [ハンガリー語(hu)](./lang/hu.json "ハンガリー語"): [kenlas](https://github.com/kenlas "kenlas") に翻訳
+* [デンマーク語(dk)](./lang/dk.json "デンマーク語"): [Munk91](https://github.com/Munk91 "Munk91") に翻訳
現在サポートされている方法
* `Constellation()`:星座を取得,例えば `おひつじ座`
* `Season()`:シーズンを取得,例えば `春`
-* `DiffForHumans()`:人間に優しい読み取り可能なフォーマットの時間差を取得します,例えば `一時間前`
-* `ToMonthString()`:月文字列を出力,例えば `いちがつ`
-* `ToShortMonthString()`:略語月文字列を出力,例えば `1がつ`
-* `ToWeekString()`:週文字列を出力,例えば `日曜日`
-* `ToShortWeekString()`:略語週文字列を出力,例えば `日`
+* `DiffForHumans()`:人が読みやすい形の時間差を取得します,例えば `1時間前`
+* `ToMonthString()`:月文字列の出力,例えば `いちがつ`
+* `ToShortMonthString()`:略語月文字列の出力,例えば `1がつ`
+* `ToWeekString()`:週文字列の出力,例えば `日曜日`
+* `ToShortWeekString()`:略語週文字列の出力,例えば `日`
###### エリアの設定
@@ -1440,10 +1383,10 @@ if c.Error != nil {
c.Now().AddHours(1).DiffForHumans() // 1 時間後
c.Now().AddHours(1).ToMonthString() // はちがつ
c.Now().AddHours(1).ToShortMonthString() // 8がつ
-c.Now().AddHours(1).ToWeekString() // もくようび
-c.Now().AddHours(1).ToShortWeekString() // 週三
-c.Now().AddHours(1).Constellation() // ししざ
-c.Now().AddHours(1).Season() // なつ
+c.Now().AddHours(1).ToWeekString() // 日曜日
+c.Now().AddHours(1).ToShortWeekString() // 日
+c.Now().AddHours(1).Constellation() // しし座
+c.Now().AddHours(1).Season() // 夏
```
###### 翻訳リソースの一部を書き換える(残りはまだ指定された `locale` ファイルの内容によって翻訳されます)
@@ -1472,7 +1415,7 @@ c.Now().Constellation() // Leo
c.Now().Season() // Summer
```
-###### すべての翻訳リソースを書き換えます
+###### すべての翻訳リソースを書き換える
```go
lang := carbon.NewLanguage()
@@ -1509,7 +1452,7 @@ c.Now().Constellation() // leo
c.Now().Season() // summer
```
-##### 模擬テスト
+##### テスト
```go
c := carbon.SetTimezone(carbon.UTC)
@@ -1528,7 +1471,7 @@ c.Now().IsSetTestNow() // false
##### エラー処理
-> 複数のエラーが発生した場合、最初のエラーだけを返します。前のエラーは削除された後、次のエラーに戻ります
+> 複数のエラーが発生した場合は最初のエラーだけを返します。前のエラーは削除された後に次のエラーに戻ります
```go
c := carbon.SetTimezone("xxx").Parse("2020-08-05")
@@ -1546,19 +1489,19 @@ invalid timezone "xxx", please see the file "$GOROOT/lib/time/zoneinfo.zip" for
| 記号 | 説明 | 長さ | 範囲 | 例 |
| :------------: | :------------: |:------:|:----------------:| :------------: |
-| d | 月の中の何日目ですか | 2 | 01-31 | 02 |
-| D | 略語は何曜日を表しますか | 3 | Mon-Sun | Mon |
-| j | 月の中の何日目ですか | - | 1-31 | 2 |
+| d | 月の日(2桁でパディング) | 2 | 01-31 | 02 |
+| D | 略語の曜日 | 3 | Mon-Sun | Mon |
+| j | 月の日(パディングしない) | - | 1-31 | 2 |
| S | 何日目の英語の略語の接尾語,普通はjと協力して使います | 2 | st/nd/rd/th | th |
-| l | 完全な単語は何曜日を表しますか | - | Monday-Sunday | Monday |
-| F | 完全な単語は月を表しますか | - | January-December | January |
-| m | 数字が示す月は | 2 | 01-12 | 01 |
+| l | 曜日 | - | Monday-Sunday | Monday |
+| F | 月 | - | January-December | January |
+| m | 月(2桁でパディング) | 2 | 01-12 | 01 |
| M | 略語の月 | 3 | Jan-Dec | Jan |
-| n | 数字が示す月 | - | 1-12 | 1 |
-| Y | 数字が示す年 | 4 | 0000-9999 | 2006 |
-| y | 数字が示す年 | 2 | 00-99 | 06 |
-| a | 小文字の午前と午後の標識 | 2 | am/pm | pm |
-| A | 大文字の午前と午後の表示 | 2 | AM/PM | PM |
+| n | 月(パディングしない) | - | 1-12 | 1 |
+| Y | 年 | 4 | 0000-9999 | 2006 |
+| y | 年(下2桁) | 2 | 00-99 | 06 |
+| a | 小文字の午前と午後 | 2 | am/pm | pm |
+| A | 大文字の午前と午後 | 2 | AM/PM | PM |
| g | 時間, 12時間のフォーマット | - | 1-12 | 3 |
| G | 時間, 24時間のフォーマット | - | 0-23 | 15 |
| h | 時間, 12時間のフォーマット | 2 | 00-11 | 03 |
@@ -1566,35 +1509,36 @@ invalid timezone "xxx", please see the file "$GOROOT/lib/time/zoneinfo.zip" for
| i | 分 | 2 | 01-59 | 04 |
| s | 秒 | 2 | 01-59 | 05 |
| O | グリニッジとの時間差の時間数 | - | - | -0700 |
-| P | グリニッジと時間の差の時間数, 時間と分の間にコロンがあります | - | - | -07:00 |
+| P | グリニッジと時間の差の時間数, 時間と分の間にコロンあり | - | - | -07:00 |
| T | タイムゾーンの略語 | - | - | MST |
-| W | ISO8601 フォーマットの数字は年の中の第数週を表します | 2 | 1-52 | 01 |
-| N | ISO8601 フォーマットの数字は曜日の中の何日目を表しますか | 2 | 01-07 | 02 |
-| L | うるう年かどうか, うるう年が1であれば, 0です | 1 | 0-1 | 0 |
-| U | 秒タイムスタンプを | - | - | 1596604455 |
-| V | ミリ秒のタイムスタンプを | - | - | 1596604455666 |
-| X | マイクロ秒タイムスタンプを | - | - | 1596604455666666 |
-| Z | ナノ秒タイムスタンプを | - | - | 1596604455666666666 |
+| W | ISO8601 フォーマットの数字は年の中の第何週(2桁でパディング) | 2 | 1-52 | 01 |
+| N | ISO8601 フォーマットの数字は曜日(2桁でパディング) | 2 | 01-07 | 02 |
+| L | うるう年かどうか, うるう年が1であれば, 0 | 1 | 0-1 | 0 |
+| U | 秒タイムスタンプ | - | - | 1596604455 |
+| V | ミリ秒のタイムスタンプ | - | - | 1596604455666 |
+| X | マイクロ秒タイムスタンプ | - | - | 1596604455666666 |
+| Z | ナノ秒タイムスタンプ | - | - | 1596604455666666666 |
| v | ミリ秒 | - | 1-999 | 999 |
| u | マイクロ秒| - | 1-999999 | 999999 |
| x | ナノ秒 | - | 1-999999999 | 999999999 |
-| w | 数字の表示の曜日 | 1 | 0-6 | 1 |
+| w | 数字表示の曜日 | 1 | 0-6 | 1 |
| t | 月の総日数 | 2 | 28-31 | 31 |
-| z | 年の中の何日目 | - | 1-365 | 2 |
-| e | 位置 | - | - | America/New_York |
-| Q | 季節 | 1 | 1-4 | 1 |
+| z | 年間積算日 | - | 1-365 | 2 |
+| e | リージョン | - | - | America/New_York |
+| Q | 四半期 | 1 | 1-4 | 1 |
| C | 世紀 | - | 0-99 | 21 |
-#### 人気のある問題
+#### FAQ
1、v1とv2のバージョンの違いは何ですか?
> APIのv1バージョンとv2バージョンに違いはありませんが `language.go`
> での翻訳リソースファイルの実装は異なります。v1は、サードパーティの拡張ライブラリ [packr](https://github.com/gobuffalo/packr) によって実装されています,v2は、 `golang1.16`
> の後に組み込みの標準ライブラリ [embed](https://pkg.go.dev/embed) によって実装されています。goバージョンが1.16より大きい場合は、v2バージョンを使用することをお勧めします。それ以外の場合は、v1バージョンを使用する必要があります。
-#### 参考文献
+#### 参考
* [briannesbitt/carbon](https://github.com/briannesbitt/Carbon)
+* [nodatime/nodatime](https://github.com/nodatime/nodatime)
* [jinzhu/now](https://github.com/jinzhu/now)
* [goframe/gtime](https://github.com/gogf/gf/tree/master/os/gtime)
* [jodaOrg/joda-time](https://github.com/jodaOrg/joda-time)
@@ -1602,16 +1546,16 @@ invalid timezone "xxx", please see the file "$GOROOT/lib/time/zoneinfo.zip" for
* [moment/moment](https://github.com/moment/moment)
* [iamkun/dayjs](https://github.com/iamkun/dayjs)
-#### 寄稿者
+#### コントリビューター
`Carbon` に貢献してくれた以下のすべてに感謝します:
-
+
#### スポンサー
`Carbon` は非営利のオープンソースプロジェクトです,`Carbon` をサポートしたい場合は、開発者のために [コーヒーを1杯購入](https://opencollective.com/go-carbon) できます
-#### ありがとう
+#### 謝辞
`Carbon` は無料の JetBrains オープンソースライセンスを取得しました,これに感謝します
diff --git a/vendor/github.com/golang-module/carbon/v2/README.md b/vendor/github.com/dromara/carbon/v2/README.md
similarity index 92%
rename from vendor/github.com/golang-module/carbon/v2/README.md
rename to vendor/github.com/dromara/carbon/v2/README.md
index 40fc2e2f..8c717e3a 100644
--- a/vendor/github.com/golang-module/carbon/v2/README.md
+++ b/vendor/github.com/dromara/carbon/v2/README.md
@@ -1,12 +1,11 @@
# Carbon
-[![Carbon Release](https://img.shields.io/github/release/golang-module/carbon.svg)](https://github.com/golang-module/carbon/releases)
-[![Go Test](https://github.com/golang-module/carbon/actions/workflows/test.yml/badge.svg)](https://github.com/golang-module/carbon/actions)
-[![Go Report Card](https://goreportcard.com/badge/github.com/golang-module/carbon/v2)](https://goreportcard.com/report/github.com/golang-module/carbon/v2)
-[![Go Coverage](https://codecov.io/gh/golang-module/carbon/branch/master/graph/badge.svg)](https://codecov.io/gh/golang-module/carbon)
-[![Goproxy.cn](https://goproxy.cn/stats/github.com/golang-module/carbon/badges/download-count.svg)](https://goproxy.cn)
-[![Carbon Doc](https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/golang-module/carbon/v2)
-[![License](https://img.shields.io/github/license/golang-module/carbon)](https://github.com/golang-module/carbon/blob/master/LICENSE)
+[![Carbon Release](https://img.shields.io/github/release/dromara/carbon.svg)](https://github.com/dromara/carbon/releases)
+[![Go Test](https://github.com/dromara/carbon/actions/workflows/test.yml/badge.svg)](https://github.com/dromara/carbon/actions)
+[![Go Report Card](https://goreportcard.com/badge/github.com/dromara/carbon/v2)](https://goreportcard.com/report/github.com/dromara/carbon/v2)
+[![Go Coverage](https://codecov.io/gh/dromara/carbon/branch/master/graph/badge.svg)](https://codecov.io/gh/dromara/carbon)
+[![Carbon Doc](https://img.shields.io/badge/go.dev-reference-brightgreen?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/dromara/carbon/v2)
+[![License](https://img.shields.io/github/license/dromara/carbon)](https://github.com/dromara/carbon/blob/master/LICENSE)
English | [简体中文](README.cn.md) | [日本語](README.jp.md)
@@ -15,42 +14,38 @@ English | [简体中文](README.cn.md) | [日本語](README.jp.md)
A simple, semantic and developer-friendly golang package for time, has been included
by [awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go")
-[github.com/golang-module/carbon](https://github.com/golang-module/carbon "github.com/golang-module/carbon")
+#### Repository
-[gitee.com/golang-module/carbon](https://gitee.com/golang-module/carbon "gitee.com/golang-module/carbon")
+[github.com/dromara/carbon](https://github.com/dromara/carbon "github.com/dromara/carbon")
+
+[gitee.com/dromara/carbon](https://gitee.com/dromara/carbon "gitee.com/dromara/carbon")
+
+[gitcode.com/dromara/carbon](https://gitcode.com/dromara/carbon "gitcode.com/dromara/carbon")
#### Installation
-##### Go version >= 1.16 (recommend)
+##### go version >= 1.17
```go
// By github
-go get -u github.com/golang-module/carbon/v2
-
-import "github.com/golang-module/carbon/v2"
+go get -u github.com/dromara/carbon/v2
+import "github.com/dromara/carbon/v2"
// By gitee
-go get -u gitee.com/golang-module/carbon/v2
+go get -u gitee.com/dromara/carbon/v2
+import "gitee.com/dromara/carbon/v2"
-import "gitee.com/golang-module/carbon/v2"
+// By gitcode
+go get -u gitcode.com/dromara/carbon/v2
+import "gitee.com/dromara/gitcode/v2"
```
-##### Go version < 1.16 (must)
+`Carbon` was donated to the [dromara](https://dromara.org/ "dromara") organization, the repository url has changed. If the previous repository used was `golang-module/carbon`, please replace the original repository with the new repository in `go.mod`, or execute the following command
```go
-// By github
-go get -u github.com/golang-module/carbon
-
-import "github.com/golang-module/carbon"
-
-// By gitee
-go get -u gitee.com/golang-module/carbon
-
-import "gitee.com/golang-module/carbon"
+go mod edit -replace github.com/golang-module/carbon/v2=github.com/dromara/carbon/v2
```
-> Please refer to FAQ for the difference between v1 and v2, v1 is no longer updated, only maintained.
-
#### Usage and example
> Assuming the current time is 2020-08-05 13:14:15.999999999 +0800 CST
@@ -60,13 +55,12 @@ import "gitee.com/golang-module/carbon"
```go
carbon.SetDefault(carbon.Default{
Layout: carbon.DateTimeLayout,
- Timezone: carbon.Local,
+ Timezone: carbon.UTC,
WeekStartsAt: carbon.Sunday,
- Locale: "en",
+ Locale: "en", // value range: translate file name in the lang directory, excluding file suffix
})
```
-
-> If not set, the default layout is `2006-01-02 15:04:05`, the default timezone is `Local`, the default week start date is `Sunday` and the default language locale is `en`
+> Suggest setting in the entry file such as `main.go`
##### Convert between `Carbon` and `time.Time`
@@ -578,6 +572,11 @@ tomorrow := carbon.Tomorrow()
carbon.Max(yesterday, today, tomorrow) // tomorrow
// Return the minimum Carbon instance
carbon.Min(yesterday, today, tomorrow) // yesterday
+
+// Return a Carbon instance for the greatest supported date
+carbon.MaxValue().ToString() // 9999-12-31 23:59:59.999999999 +0000 UTC
+// Return a Carbon instance for the lowest supported date
+carbon.MinValue().ToString() // -9998-01-01 00:00:00 +0000 UTC
```
##### Comparison
@@ -592,7 +591,7 @@ carbon.Parse("00:00:00").IsDST() // false
carbon.Parse("2023-01-01", "Australia/Brisbane").IsDST() // false
carbon.Parse("2023-01-01", "Australia/Sydney").IsDST() // true
-// Whether is zero time
+// Whether is zero time(0001-01-01 00:00:00 +0000 UTC)
carbon.Parse("").IsZero() // true
carbon.Parse("0").IsZero() // true
carbon.Parse("0000-00-00 00:00:00").IsZero() // true
@@ -1206,172 +1205,111 @@ carbon.Parse("2020-08-05 13:14:15").IsWinter() // false
##### JSON
-###### Scene one: all time fields have the same format
```go
-carbon.SetDefault(carbon.Default{
- Layout: carbon.DateTimeLayout,
-})
-
type Person struct {
Name string `json:"name"`
- Age int `json:"age"`
-
- Field1 carbon.Carbon `json:"field1"`
- Field2 carbon.Carbon `json:"field2"`
- Field3 carbon.Carbon `json:"field3"`
- Field4 carbon.Carbon `json:"field4"`
-
- Field5 carbon.Carbon `json:"field5"`
- Field6 carbon.Carbon `json:"field6"`
- Field7 carbon.Carbon `json:"field7"`
- Field8 carbon.Carbon `json:"field8"`
+ Age int `json:"age"`
+ Birthday0 carbon.Carbon `json:"birthday0"`
+ Birthday1 carbon.DateTime `json:"birthday1"`
+ Birthday2 carbon.DateTimeMilli `json:"birthday2"`
+ Birthday3 carbon.DateTimeMicro `json:"birthday3"`
+ Birthday4 carbon.DateTimeNano `json:"birthday4"`
+ GraduatedAt1 carbon.Date `json:"graduated_at1"`
+ GraduatedAt2 carbon.DateMilli `json:"graduated_at2"`
+ GraduatedAt3 carbon.DateMicro `json:"graduated_at3"`
+ GraduatedAt4 carbon.DateNano `json:"graduated_at4"`
+ OperatedAt1 carbon.Time `json:"operated_at1"`
+ OperatedAt2 carbon.TimeMilli `json:"operated_at2"`
+ OperatedAt3 carbon.TimeMicro `json:"operated_at3"`
+ OperatedAt4 carbon.TimeNano `json:"operated_at4"`
+ CreatedAt1 carbon.Timestamp `json:"created_at1"`
+ CreatedAt2 carbon.TimestampMilli `json:"created_at2"`
+ CreatedAt3 carbon.TimestampMicro `json:"created_at3"`
+ CreatedAt4 carbon.TimestampNano `json:"created_at4"`
}
-now := carbon.Parse("2020-08-05 13:14:15", carbon.PRC)
person := Person {
- Name: "gouguoyin",
- Age: 18,
-
- Field1: now,
- Field2: now,
- Field3: now,
- Field4: now,
- Field5: now,
- Field6: now,
- Field7: now,
- Field8: now,
+ Name: "gouguoyin",
+ Age: 18,
+ Birthday0: carbon.Now().SubYears(18),
+ Birthday1: carbon.NewDateTime(carbon.Now().SubYears(18)),
+ Birthday2: carbon.NewDateTimeMilli(carbon.Now().SubYears(18)),
+ Birthday3: carbon.NewDateTimeMicro(carbon.Now().SubYears(18)),
+ Birthday4: carbon.NewDateTimeNano(carbon.Now().SubYears(18)),
+ GraduatedAt1: carbon.NewDate(carbon.Now()),
+ GraduatedAt2: carbon.NewDateMilli(carbon.Now()),
+ GraduatedAt3: carbon.NewDateMicro(carbon.Now()),
+ GraduatedAt4: carbon.NewDateNano(carbon.Now()),
+ OperatedAt1: carbon.NewTime(carbon.Now()),
+ OperatedAt2: carbon.NewTimeMilli(carbon.Now()),
+ OperatedAt3: carbon.NewTimeMicro(carbon.Now()),
+ OperatedAt4: carbon.NewTimeNano(carbon.Now()),
+ CreatedAt1: carbon.NewTimestamp(carbon.Now()),
+ CreatedAt2: carbon.NewTimestampMilli(carbon.Now()),
+ CreatedAt3: carbon.NewTimestampMicro(carbon.Now()),
+ CreatedAt4: carbon.NewTimestampNano(carbon.Now()),
}
-data, marshalErr := json.Marshal(person)
-if marshalErr != nil {
+data, err := json.Marshal(&person)
+if err != nil {
// Error handle...
- log.Fatal(marshalErr)
+ log.Fatal(err)
}
fmt.Printf("%s", data)
// Output
{
"name": "gouguoyin",
"age": 18,
- "field1": "2020-08-05 13:14:15",
- "field2": "2020-08-05 13:14:15",
- "field3": "2020-08-05 13:14:15",
- "field4": "2020-08-05 13:14:15",
- "field5": "2020-08-05 13:14:15",
- "field6": "2020-08-05 13:14:15",
- "field7": "2020-08-05 13:14:15",
- "field8": "2020-08-05 13:14:15"
+ "birthday0": "2003-07-16 13:14:15",
+ "birthday1": "2003-07-16 13:14:15",
+ "birthday2": "2003-07-16 13:14:15.999",
+ "birthday3": "2003-07-16 13:14:15.999999",
+ "birthday4": "2003-07-16 13:14:15.999999999",
+ "graduated_at1": "2020-08-05",
+ "graduated_at2": "2020-08-05.999",
+ "graduated_at3": "2020-08-05.999999",
+ "graduated_at4": "2020-08-05.999999999",
+ "operated_at1": "13:14:15",
+ "operated_at2": "13:14:15.999",
+ "operated_at3": "13:14:15.999999",
+ "operated_at4": "13:14:15.999999999",
+ "created_at1": 1596604455,
+ "created_at2": 1596604455999,
+ "created_at3": 1596604455999999,
+ "created_at4": 1596604455999999999
}
-var person Person
-unmarshalErr := json.Unmarshal(data, &person)
-if unmarshalErr != nil {
+err := json.Unmarshal([]byte(data), &person)
+if err != nil {
// Error handle...
- log.Fatal(unmarshalErr)
-}
-
-fmt.Printf("%s", person.Field1) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field2) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field3) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field4) // 2020-08-05 13:14:15
-
-fmt.Printf("%s", person.Field5) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field6) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field7) // 2020-08-05 13:14:15
-fmt.Printf("%s", person.Field8) // 2020-08-05 13:14:15
-```
-
-###### Scene two: different time fields have different formats
-> Please refer to here for all supported type values. If the `carbon` tag is not set, the default is `layout:2006-01-02 15:04:05`, if the `tz` tag is not set, the default is `Local`
-
-```go
-type Person struct {
- Name string `json:"name"`
- Age int `json:"age"`
-
- Field1 carbon.Carbon `json:"field1"`
-
- Field2 carbon.Carbon `json:"field2" carbon:"type:date" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"type:time" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"type:dateTime" tz:"PRC"`
- // or
- Field2 carbon.Carbon `json:"field2" carbon:"layout:2006-01-02" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"layout:15:04:05" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"layout:2006-01-02 15:04:05" tz:"PRC"`
- // or
- Field2 carbon.Carbon `json:"field2" carbon:"format:Y-m-d" tz:"PRC"`
- Field3 carbon.Carbon `json:"field3" carbon:"format:H:i:s" tz:"PRC"`
- Field4 carbon.Carbon `json:"field4" carbon:"format:Y-m-d H:i:s" tz:"PRC"`
-
- Field5 carbon.Carbon `json:"field5" carbon:"type:timestamp" tz:"PRC"`
- Field6 carbon.Carbon `json:"field6" carbon:"type:timestampMilli" tz:"PRC"`
- Field7 carbon.Carbon `json:"field7" carbon:"type:timestampMicro" tz:"PRC"`
- Field8 carbon.Carbon `json:"field8" carbon:"type:timestampNano" tz:"PRC"`
+ log.Fatal(err)
}
-now := Parse("2020-08-05 13:14:15", carbon.PRC)
-person := Person {
- Name: "gouguoyin",
- Age: 18,
-
- Field1: now,
- Field2: now,
- Field3: now,
- Field4: now,
- Field5: now,
- Field6: now,
- Field7: now,
- Field8: now,
-}
-
-loadErr := carbon.LoadTag(&person)
-if loadErr != nil {
- // Error handle...
- log.Fatal(loadErr)
-}
-data, marshalErr := json.Marshal(person)
-if marshalErr != nil {
- // Error handle...
- log.Fatal(marshalErr)
-}
-fmt.Printf("%s", data)
-// Output
-{
- "name": "gouguoyin",
- "age": 18,
- "field1": "2020-08-05 13:14:15",
- "field2": "2020-08-05",
- "field3": "13:14:15",
- "field4": "2020-08-05 13:14:15",
- "field5": 1596604455,
- "field6": 1596604455999,
- "field7": 1596604455999999,
- "field8": 1596604455999999999
-}
-
-var person Person
-
-loadErr := carbon.LoadTag(&person)
-if loadErr != nil {
- // Error handle...
- log.Fatal(loadErr)
-}
-
-unmarshalErr := json.Unmarshal(data, &person)
-if unmarshalErr != nil {
- // Error handle...
- log.Fatal(unmarshalErr)
-}
-
-fmt.Printf("%s", person.Field1) // 2002-08-05 13:14:15
-fmt.Printf("%s", person.Field2) // 2020-08-05
-fmt.Printf("%s", person.Field3) // 13:14:15
-fmt.Printf("%s", person.Field4) // 2002-08-05 13:14:15
-
-fmt.Printf("%d", person.Field5) // 1596604455
-fmt.Printf("%d", person.Field6) // 1596604455999
-fmt.Printf("%d", person.Field7) // 1596604455999999
-fmt.Printf("%d", person.Field8) // 1596604455999999999
-
+person.Birthday0.String() // 2003-07-16 13:14:15
+person.Birthday1.String() // 2003-07-16 13:14:15
+person.Birthday2.String() // 2003-07-16 13:14:15.999
+person.Birthday3.String() // 2003-07-16 13:14:15.999999
+person.Birthday4.String() // 2003-07-16 13:14:15.999999999
+
+person.GraduatedAt1.String() // 2020-08-05
+person.GraduatedAt2.String() // 2020-08-05.999
+person.GraduatedAt3.String() // 2020-08-05.999999
+person.GraduatedAt4.String() // 2020-08-05.999999999
+
+person.OperatedAt1.String() // 13:14:15
+person.OperatedAt2.String() // 13:14:15.999
+person.OperatedAt3.String() // 13:14:15.999999
+person.OperatedAt4.String() // 13:14:15.999999999
+
+person.CreatedAt1.String() // "1596604455"
+person.CreatedAt2.String() // "1596604455999"
+person.CreatedAt3.String() // "1596604455999999"
+person.CreatedAt4.String() // "1596604455999999999"
+
+person.CreatedAt1.Int64() // 1596604455
+person.CreatedAt2.Int64() // 1596604455999
+person.CreatedAt3.Int64() // 1596604455999999
+person.CreatedAt4.Int64() // 1596604455999999999
```
##### Calendar
@@ -1415,6 +1353,10 @@ The following languages are supported
* [VietNamese(vi)](./lang/vi.json "VietNam"): translated by [culy247](https://github.com/culy247 "culy247")
* [Hindi(hi)](./lang/hi.json "India"): translated by [chauhan17nitin](https://github.com/chauhan17nitin "chauhan17nitin")
* [Polish(pl)](./lang/pl.json "Polish"): translated by [gouguoyin](https://github.com/gouguoyin "gouguoyin")
+* [Bulgarian(bg)](./lang/bg.json "Bulgarian"): translated by [yuksbg](https://github.com/yuksbg "yuksbg")
+* [Arabic(ar)](./lang/ar.json "Arabic"): translated by [zumoshi](https://github.com/zumoshi "zumoshi")
+* [Hungarian(hu)](./lang/hu.json "Hungarian"): translated by [kenlas](https://github.com/kenlas "kenlas")
+* [Dansk(dk)](./lang/dk.json "Dansk"): translated by [Munk91](https://github.com/Munk91 "Munk91")
The following methods are supported
@@ -1594,6 +1536,7 @@ invalid timezone "xxx", please see the file "$GOROOT/lib/time/zoneinfo.zip" for
#### References
* [briannesbitt/carbon](https://github.com/briannesbitt/Carbon)
+* [nodatime/nodatime](https://github.com/nodatime/nodatime)
* [jinzhu/now](https://github.com/jinzhu/now)
* [goframe/gtime](https://github.com/gogf/gf/tree/master/os/gtime)
* [jodaOrg/joda-time](https://github.com/jodaOrg/joda-time)
@@ -1604,7 +1547,7 @@ invalid timezone "xxx", please see the file "$GOROOT/lib/time/zoneinfo.zip" for
#### Contributors
Thanks to all of the following who contributed to `Carbon`:
-
+
#### Sponsors
diff --git a/vendor/github.com/golang-module/carbon/v2/boundary.go b/vendor/github.com/dromara/carbon/v2/boundary.go
similarity index 92%
rename from vendor/github.com/golang-module/carbon/v2/boundary.go
rename to vendor/github.com/dromara/carbon/v2/boundary.go
index e08422e5..879fadfa 100644
--- a/vendor/github.com/golang-module/carbon/v2/boundary.go
+++ b/vendor/github.com/dromara/carbon/v2/boundary.go
@@ -3,7 +3,7 @@ package carbon
// StartOfCentury returns a Carbon instance for start of the century.
// 本世纪开始时间
func (c Carbon) StartOfCentury() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(c.Year()/YearsPerCentury*YearsPerCentury, 1, 1, 0, 0, 0, 0)
@@ -12,7 +12,7 @@ func (c Carbon) StartOfCentury() Carbon {
// EndOfCentury returns a Carbon instance for end of the century.
// 本世纪结束时间
func (c Carbon) EndOfCentury() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(c.Year()/YearsPerCentury*YearsPerCentury+99, 12, 31, 23, 59, 59, 999999999)
@@ -21,7 +21,7 @@ func (c Carbon) EndOfCentury() Carbon {
// StartOfDecade returns a Carbon instance for start of the decade.
// 本年代开始时间
func (c Carbon) StartOfDecade() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(c.Year()/YearsPerDecade*YearsPerDecade, 1, 1, 0, 0, 0, 0)
@@ -30,7 +30,7 @@ func (c Carbon) StartOfDecade() Carbon {
// EndOfDecade returns a Carbon instance for end of the decade.
// 本年代结束时间
func (c Carbon) EndOfDecade() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(c.Year()/YearsPerDecade*YearsPerDecade+9, 12, 31, 23, 59, 59, 999999999)
@@ -39,7 +39,7 @@ func (c Carbon) EndOfDecade() Carbon {
// StartOfYear returns a Carbon instance for start of the year.
// 本年开始时间
func (c Carbon) StartOfYear() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(c.Year(), 1, 1, 0, 0, 0, 0)
@@ -48,7 +48,7 @@ func (c Carbon) StartOfYear() Carbon {
// EndOfYear returns a Carbon instance for end of the year.
// 本年结束时间
func (c Carbon) EndOfYear() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(c.Year(), 12, 31, 23, 59, 59, 999999999)
@@ -57,7 +57,7 @@ func (c Carbon) EndOfYear() Carbon {
// StartOfQuarter returns a Carbon instance for start of the quarter.
// 本季度开始时间
func (c Carbon) StartOfQuarter() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, quarter, day := c.Year(), c.Quarter(), 1
@@ -67,7 +67,7 @@ func (c Carbon) StartOfQuarter() Carbon {
// EndOfQuarter returns a Carbon instance for end of the quarter.
// 本季度结束时间
func (c Carbon) EndOfQuarter() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, quarter, day := c.Year(), c.Quarter(), 30
@@ -83,7 +83,7 @@ func (c Carbon) EndOfQuarter() Carbon {
// StartOfMonth returns a Carbon instance for start of the month.
// 本月开始时间
func (c Carbon) StartOfMonth() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, _ := c.Date()
@@ -93,7 +93,7 @@ func (c Carbon) StartOfMonth() Carbon {
// EndOfMonth returns a Carbon instance for end of the month.
// 本月结束时间
func (c Carbon) EndOfMonth() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, _ := c.Date()
@@ -103,7 +103,7 @@ func (c Carbon) EndOfMonth() Carbon {
// StartOfWeek returns a Carbon instance for start of the week.
// 本周开始时间
func (c Carbon) StartOfWeek() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
dayOfWeek, weekStartsAt := c.DayOfWeek(), int(c.weekStartsAt)
@@ -113,7 +113,7 @@ func (c Carbon) StartOfWeek() Carbon {
// EndOfWeek returns a Carbon instance for end of the week.
// 本周结束时间
func (c Carbon) EndOfWeek() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
dayOfWeek, weekEndsAt := c.DayOfWeek(), int(c.weekStartsAt)+DaysPerWeek-1
@@ -123,7 +123,7 @@ func (c Carbon) EndOfWeek() Carbon {
// StartOfDay returns a Carbon instance for start of the day.
// 本日开始时间
func (c Carbon) StartOfDay() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -133,7 +133,7 @@ func (c Carbon) StartOfDay() Carbon {
// EndOfDay returns a Carbon instance for end of the day.
// 本日结束时间
func (c Carbon) EndOfDay() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -143,7 +143,7 @@ func (c Carbon) EndOfDay() Carbon {
// StartOfHour returns a Carbon instance for start of the hour.
// 小时开始时间
func (c Carbon) StartOfHour() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -153,7 +153,7 @@ func (c Carbon) StartOfHour() Carbon {
// EndOfHour returns a Carbon instance for end of the hour.
// 小时结束时间
func (c Carbon) EndOfHour() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -163,7 +163,7 @@ func (c Carbon) EndOfHour() Carbon {
// StartOfMinute returns a Carbon instance for start of the minute.
// 分钟开始时间
func (c Carbon) StartOfMinute() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, _ := c.DateTime()
@@ -173,7 +173,7 @@ func (c Carbon) StartOfMinute() Carbon {
// EndOfMinute returns a Carbon instance for end of the minute.
// 分钟结束时间
func (c Carbon) EndOfMinute() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, _ := c.DateTime()
@@ -183,7 +183,7 @@ func (c Carbon) EndOfMinute() Carbon {
// StartOfSecond returns a Carbon instance for start of the second.
// 秒开始时间
func (c Carbon) StartOfSecond() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, second := c.DateTime()
@@ -193,7 +193,7 @@ func (c Carbon) StartOfSecond() Carbon {
// EndOfSecond returns a Carbon instance for end of the second.
// 秒结束时间
func (c Carbon) EndOfSecond() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, second := c.DateTime()
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar.go b/vendor/github.com/dromara/carbon/v2/calendar.go
similarity index 83%
rename from vendor/github.com/golang-module/carbon/v2/calendar.go
rename to vendor/github.com/dromara/carbon/v2/calendar.go
index 1fdbc62a..00fbd4ae 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar.go
+++ b/vendor/github.com/dromara/carbon/v2/calendar.go
@@ -1,9 +1,9 @@
package carbon
import (
- "github.com/golang-module/carbon/v2/calendar/julian"
- "github.com/golang-module/carbon/v2/calendar/lunar"
- "github.com/golang-module/carbon/v2/calendar/persian"
+ "github.com/dromara/carbon/v2/calendar/julian"
+ "github.com/dromara/carbon/v2/calendar/lunar"
+ "github.com/dromara/carbon/v2/calendar/persian"
)
// Lunar converts Carbon instance to Lunar instance.
@@ -50,7 +50,12 @@ func (c Carbon) Persian() (p persian.Persian) {
// CreateFromPersian creates a Carbon instance from Persian date and time.
// 从 波斯日期 创建 Carbon 实例
-func CreateFromPersian(year, month, day, hour, minute, second int) Carbon {
- t := persian.FromPersian(year, month, day, hour, minute, second).ToGregorian().Time
+func CreateFromPersian(year, month, day, hour, minute, second int) (c Carbon) {
+ p := persian.FromPersian(year, month, day, hour, minute, second)
+ if p.Error != nil {
+ c.Error = p.Error
+ return
+ }
+ t := p.ToGregorian().Time
return CreateFromStdTime(t)
}
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/gregorian.go b/vendor/github.com/dromara/carbon/v2/calendar/gregorian.go
similarity index 87%
rename from vendor/github.com/golang-module/carbon/v2/calendar/gregorian.go
rename to vendor/github.com/dromara/carbon/v2/calendar/gregorian.go
index 527ea3c6..647c2e3b 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/gregorian.go
+++ b/vendor/github.com/dromara/carbon/v2/calendar/gregorian.go
@@ -2,9 +2,14 @@
package calendar
import (
+ "fmt"
"time"
)
+var InvalidDateError = func() error {
+ return fmt.Errorf("invalid gregorian date, please make sure the date is valid")
+}
+
// month constants
// 月份常量
const (
@@ -34,6 +39,8 @@ const (
Sunday = "Sunday" // 周日
)
+// number constants
+// 数字常量
const (
YearsPerMillennium = 1000 // 每千年1000年
YearsPerCentury = 100 // 每世纪100年
@@ -133,6 +140,18 @@ func NewGregorian(t time.Time) (g Gregorian) {
return
}
+// MaxValue returns a Gregorian instance for the greatest supported date.
+// 返回 Gregorian 的最大值
+func MaxValue() Gregorian {
+ return NewGregorian(time.Date(9999, 12, 31, 23, 59, 59, 999999999, time.UTC))
+}
+
+// MinValue returns a Gregorian instance for the lowest supported date.
+// 返回 Gregorian 的最小值
+func MinValue() Gregorian {
+ return NewGregorian(time.Date(-9998, 1, 1, 0, 0, 0, 0, time.UTC))
+}
+
// Date gets gregorian year, month, and day like 2020, 8, 5.
// 获取公历年、月、日
func (g Gregorian) Date() (year, month, day int) {
@@ -238,6 +257,15 @@ func (g Gregorian) IsZero() bool {
return g.Time.IsZero()
}
+// IsValid reports whether is a valid gregorian date.
+// 是否是有效的年份
+func (g Gregorian) IsValid() bool {
+ if g.Year() >= MinValue().Year() && g.Year() <= MaxValue().Year() && g.Month() >= MinValue().Month() && g.Month() <= MaxValue().Month() && g.Day() >= MinValue().Day() && g.Day() <= MaxValue().Day() {
+ return true
+ }
+ return false
+}
+
// IsLeapYear reports whether is a leap year.
// 是否是闰年
func (g Gregorian) IsLeapYear() bool {
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/julian/README.cn.md b/vendor/github.com/dromara/carbon/v2/calendar/julian/README.cn.md
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/calendar/julian/README.cn.md
rename to vendor/github.com/dromara/carbon/v2/calendar/julian/README.cn.md
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/julian/README.jp.md b/vendor/github.com/dromara/carbon/v2/calendar/julian/README.jp.md
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/calendar/julian/README.jp.md
rename to vendor/github.com/dromara/carbon/v2/calendar/julian/README.jp.md
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/julian/README.md b/vendor/github.com/dromara/carbon/v2/calendar/julian/README.md
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/calendar/julian/README.md
rename to vendor/github.com/dromara/carbon/v2/calendar/julian/README.md
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/julian/julian.go b/vendor/github.com/dromara/carbon/v2/calendar/julian/julian.go
similarity index 98%
rename from vendor/github.com/golang-module/carbon/v2/calendar/julian/julian.go
rename to vendor/github.com/dromara/carbon/v2/calendar/julian/julian.go
index 5fcad29c..4cde2f28 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/julian/julian.go
+++ b/vendor/github.com/dromara/carbon/v2/calendar/julian/julian.go
@@ -6,7 +6,7 @@ import (
"strconv"
"time"
- "github.com/golang-module/carbon/v2/calendar"
+ "github.com/dromara/carbon/v2/calendar"
)
var (
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.cn.md b/vendor/github.com/dromara/carbon/v2/calendar/lunar/README.cn.md
similarity index 94%
rename from vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.cn.md
rename to vendor/github.com/dromara/carbon/v2/calendar/lunar/README.cn.md
index 33d49270..c792e535 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.cn.md
+++ b/vendor/github.com/dromara/carbon/v2/calendar/lunar/README.cn.md
@@ -45,9 +45,26 @@ carbon.Parse("2020-08-05 13:14:15").Lunar().ToDayString() // 十六
// 获取农历日期字符串
carbon.Parse("2020-08-05 13:14:15").Lunar().ToDateString() // 二零二零年六月十六
-// 是否是零值时间
-carbon.Parse("0000-00-00 00:00:00").Lunar().IsZero() // true
-carbon.Parse("2020-08-05 13:14:15").Lunar().IsZero() // false
+```
+
+##### 将 `农历` 转化成 `公历`
+
+```go
+// 将农历 二零二三年腊月十一 转化为 公历
+carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
+// 将农历 二零二三年二月十一 转化为 公历
+carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2023-03-02 00:00:00
+// 将农历 二零二三年闰二月十一 转化为 公历
+carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
+```
+
+##### 日期判断
+
+```go
+
+// 是否是合法农历日期
+carbon.Parse("0000-00-00 00:00:00").Lunar().IsValid() // false
+carbon.Parse("2020-08-05 13:14:15").Lunar().IsValid() // true
// 是否是农历闰年
carbon.Parse("2020-08-05 13:14:15").Lunar().IsLeapYear() // true
@@ -78,15 +95,4 @@ carbon.Parse("2020-08-05 13:14:15").Lunar().IsRoosterYear() // false
carbon.Parse("2020-08-05 13:14:15").Lunar().IsDogYear() // false
// 是否是猪年
carbon.Parse("2020-08-05 13:14:15").Lunar().IsPigYear() // false
-```
-
-##### 将 `农历` 转化成 `公历`
-
-```go
-// 将农历 二零二三年腊月十一 转化为 公历
-carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
-// 将农历 二零二三年二月十一 转化为 公历
-carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2023-03-02 00:00:00
-// 将农历 二零二三年闰二月十一 转化为 公历
-carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.jp.md b/vendor/github.com/dromara/carbon/v2/calendar/lunar/README.jp.md
similarity index 94%
rename from vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.jp.md
rename to vendor/github.com/dromara/carbon/v2/calendar/lunar/README.jp.md
index 37dca326..46011ad7 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.jp.md
+++ b/vendor/github.com/dromara/carbon/v2/calendar/lunar/README.jp.md
@@ -45,9 +45,24 @@ carbon.Parse("2020-08-05 13:14:15").Lunar().ToDayString() // 十六
// 旧暦日付文字列の取得
carbon.Parse("2020-08-05 13:14:15").Lunar().ToDateString() // 二零二零年六月十六
-// ゼロ値の時間ですか
-carbon.Parse("0000-00-00 00:00:00").Lunar().IsZero() // true
-carbon.Parse("2020-08-05 13:14:15").Lunar().IsZero() // false
+```
+
+##### `旧暦`を`西暦`に変換する
+
+```go
+// 2023 年の旧暦 12 月 11 日をグレゴリオ暦に変換します
+carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
+// 旧暦の 2023 年 2 月 11 日をグレゴリオ暦に変換します
+carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2023-03-02 00:00:00
+// 旧暦 2023 年、閏 2 月 11 日をグレゴリオ暦に変換します
+carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
+```
+
+##### 日付判断
+```go
+// 合法的なペルシャ暦の日付かどうか
+carbon.Parse("0000-00-00 00:00:00").Lunar().IsValid() // false
+carbon.Parse("2020-08-05 13:14:15").Lunar().IsValid() // true
// 旧暦うるう年かどうか
carbon.Parse("2020-08-05 13:14:15").Lunar().IsLeapYear() // true
@@ -78,15 +93,5 @@ carbon.Parse("2020-08-05 13:14:15").Lunar().IsRoosterYear() // false
carbon.Parse("2020-08-05 13:14:15").Lunar().IsDogYear() // false
// 豚年かどうか
carbon.Parse("2020-08-05 13:14:15").Lunar().IsPigYear() // false
-```
-##### `旧暦`を`西暦`に変換する
-
-```go
-// 2023 年の旧暦 12 月 11 日をグレゴリオ暦に変換します
-carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
-// 旧暦の 2023 年 2 月 11 日をグレゴリオ暦に変換します
-carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2023-03-02 00:00:00
-// 旧暦 2023 年、閏 2 月 11 日をグレゴリオ暦に変換します
-carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.md b/vendor/github.com/dromara/carbon/v2/calendar/lunar/README.md
similarity index 95%
rename from vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.md
rename to vendor/github.com/dromara/carbon/v2/calendar/lunar/README.md
index 4d06122a..ad7b8b67 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/README.md
+++ b/vendor/github.com/dromara/carbon/v2/calendar/lunar/README.md
@@ -45,9 +45,24 @@ carbon.Parse("2020-08-05 13:14:15").Lunar().ToDayString() // 十六
// Get lunar date as string
carbon.Parse("2020-08-05 13:14:15").Lunar().ToDateString() // 二零二零年六月十六
-// Whether is a lunar zero time
-carbon.Parse("0000-00-00 00:00:00").Lunar().IsZero() // true
-carbon.Parse("2020-08-05 13:14:15").Lunar().IsZero() // false
+```
+
+##### Convert `Lunar` calendar to `Gregorian` calendar
+
+```go
+// Convert the Lunar Calendar December 11, 2023 to the gregorian calendar
+carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
+// Convert lunar calendar February 11, 2023 to gregorian calendar
+carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2024-03-02 00:00:00
+// Convert the Lunar Calendar Leap February 11, 2024 to the gregorian calendar
+carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
+```
+
+##### Comparison
+```go
+// Whether is a valid lunar date
+carbon.Parse("0000-00-00 00:00:00").Lunar().IsValid() // false
+carbon.Parse("2020-08-05 13:14:15").Lunar().IsValid() // true
// Whether is a lunar leap year
carbon.Parse("2020-08-05 13:14:15").Lunar().IsLeapYear() // true
@@ -78,15 +93,5 @@ carbon.Parse("2020-08-05 13:14:15").Lunar().IsRoosterYear() // false
carbon.Parse("2020-08-05 13:14:15").Lunar().IsDogYear() // false
// Whether is a lunar year of the dig
carbon.Parse("2020-08-05 13:14:15").Lunar().IsPigYear() // false
-```
-##### Convert `Lunar` calendar to `Gregorian` calendar
-
-```go
-// Convert the Lunar Calendar December 11, 2023 to the gregorian calendar
-carbon.CreateFromLunar(2023, 12, 11, 0, 0, 0, false).ToDateTimeString() // 2024-01-21 00:00:00
-// Convert lunar calendar February 11, 2023 to gregorian calendar
-carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, false).ToDateTimeString() // 2024-03-02 00:00:00
-// Convert the Lunar Calendar Leap February 11, 2024 to the gregorian calendar
-carbon.CreateFromLunar(2023, 2, 11, 0, 0, 0, true).ToDateTimeString() // 2023-04-01 00:00:00
```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/lunar.go b/vendor/github.com/dromara/carbon/v2/calendar/lunar/lunar.go
similarity index 84%
rename from vendor/github.com/golang-module/carbon/v2/calendar/lunar/lunar.go
rename to vendor/github.com/dromara/carbon/v2/calendar/lunar/lunar.go
index b4ec7f32..d32249a8 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/lunar/lunar.go
+++ b/vendor/github.com/dromara/carbon/v2/calendar/lunar/lunar.go
@@ -6,12 +6,10 @@ import (
"strings"
"time"
- "github.com/golang-module/carbon/v2/calendar"
+ "github.com/dromara/carbon/v2/calendar"
)
var (
- minYear, maxYear = 1900, 2100
-
numbers = []string{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"}
months = []string{"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"}
weeks = []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}
@@ -57,8 +55,8 @@ var (
0x0d520, // 2100
}
- invalidYearError = func() error {
- return fmt.Errorf("invalid year, outside of range [1900,2100]")
+ InvalidDateError = func() error {
+ return fmt.Errorf("invalid invalid date, please make sure the date is valid")
}
)
@@ -76,6 +74,32 @@ type Lunar struct {
Error error
}
+// MaxValue returns a Lunar instance for the greatest supported date.
+// 返回 Carbon 的最大值
+func MaxValue() Lunar {
+ return Lunar{
+ year: 2100,
+ month: 12,
+ day: 31,
+ hour: 23,
+ minute: 59,
+ second: 59,
+ }
+}
+
+// MinValue returns a Lunar instance for the lowest supported date.
+// 返回 Lunar 的最小值
+func MinValue() Lunar {
+ return Lunar{
+ year: 1900,
+ month: 1,
+ day: 1,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ }
+}
+
// FromGregorian creates a Gregorian instance from time.Time.
// 从标准 time.Time 创建 Gregorian 实例
func FromGregorian(t time.Time) (g Gregorian) {
@@ -92,6 +116,10 @@ func FromLunar(year, month, day, hour, minute, second int, isLeapMonth bool) (l
l.year, l.month, l.day = year, month, day
l.hour, l.minute, l.second = hour, minute, second
l.isLeapMonth = isLeapMonth
+ if !l.IsValid() {
+ l.Error = InvalidDateError()
+ return
+ }
return
}
@@ -102,10 +130,8 @@ func (g Gregorian) ToLunar() (l Lunar) {
return
}
daysInYear, daysInMonth, leapMonth := 365, 30, 0
- if g.Year() < minYear || g.Year() > maxYear {
- l.Error = invalidYearError()
- return
- }
+ maxYear, minYear := MaxValue().year, MinValue().year
+
// 与 1900-01-31 相差多少天
offset := g.diffInDays(time.Date(minYear, 1, 31, 0, 0, 0, 0, g.Location()))
for l.year = minYear; l.year <= maxYear && offset > 0; l.year++ {
@@ -146,20 +172,19 @@ func (g Gregorian) ToLunar() (l Lunar) {
}
l.day = offset + 1
l.hour, l.minute, l.second = g.Clock()
+ if !l.IsValid() {
+ l.Error = InvalidDateError()
+ return
+ }
return
}
// ToGregorian converts Lunar instance to Gregorian instance.
// 将 Lunar 实例转化为 Gregorian 实例
func (l Lunar) ToGregorian() (g Gregorian) {
- if l.IsZero() {
- return
- }
- if l.year < minYear || l.year > maxYear {
- g.Error = invalidYearError()
+ if !l.IsValid() {
return
}
-
days := l.getDaysInMonth()
offset := l.getOffsetInYear()
offset += l.getOffsetInMonth()
@@ -176,7 +201,7 @@ func (l Lunar) ToGregorian() (g Gregorian) {
// Animal gets lunar animal name like "猴".
// 获取农历生肖
func (l Lunar) Animal() string {
- if l.IsZero() {
+ if !l.IsValid() {
return ""
}
return animals[l.year%calendar.MonthsPerYear]
@@ -185,7 +210,7 @@ func (l Lunar) Animal() string {
// Festival gets lunar festival name like "春节".
// 获取农历节日
func (l Lunar) Festival() string {
- if l.IsZero() {
+ if !l.IsValid() {
return ""
}
return festivals[fmt.Sprintf("%d-%d", l.month, l.day)]
@@ -251,6 +276,7 @@ func (l Lunar) LeapMonth() int {
if l.Error != nil {
return 0
}
+ minYear := MinValue().year
if l.year-minYear < 0 {
return 0
}
@@ -260,7 +286,7 @@ func (l Lunar) LeapMonth() int {
// String implements Stringer interface and outputs a string in YYYY-MM-DD HH::ii::ss format like "2019-12-07 00:00:00".
// 实现 Stringer 接口, 输出 YYYY-MM-DD HH::ii::ss 格式字符串,如 "2019-12-07 00:00:00"
func (l Lunar) String() string {
- if l.IsZero() {
+ if !l.IsValid() {
return ""
}
return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d", l.year, l.month, l.day, l.hour, l.minute, l.second)
@@ -269,8 +295,8 @@ func (l Lunar) String() string {
// ToYearString outputs a string in lunar year format like "二零二零".
// 获取农历年份字符串,如 "二零二零"
func (l Lunar) ToYearString() (year string) {
- if l.IsZero() {
- return
+ if !l.IsValid() {
+ return ""
}
year = fmt.Sprintf("%d", l.year)
for index, number := range numbers {
@@ -282,8 +308,8 @@ func (l Lunar) ToYearString() (year string) {
// ToMonthString outputs a string in lunar month format like "正月".
// 获取农历月份字符串,如 "正月"
func (l Lunar) ToMonthString() (month string) {
- if l.IsZero() {
- return
+ if !l.IsValid() {
+ return ""
}
month = months[l.month-1] + "月"
if l.IsLeapMonth() {
@@ -295,7 +321,7 @@ func (l Lunar) ToMonthString() (month string) {
// ToWeekString outputs a string in week layout like "周一".
// 输出完整农历星期字符串,如 "周一"
func (l Lunar) ToWeekString() (month string) {
- if l.IsZero() {
+ if !l.IsValid() {
return ""
}
return weeks[l.ToGregorian().Week()]
@@ -304,8 +330,8 @@ func (l Lunar) ToWeekString() (month string) {
// ToDayString outputs a string in lunar day format like "廿一".
// 获取农历日字符串,如 "廿一"
func (l Lunar) ToDayString() (day string) {
- if l.IsZero() {
- return
+ if !l.IsValid() {
+ return ""
}
num := numbers[l.day%10]
switch {
@@ -328,25 +354,22 @@ func (l Lunar) ToDayString() (day string) {
// ToDateString outputs a string in lunar date format like "二零二零年腊月初五".
// 获取农历日期字符串,如 "二零二零年腊月初五"
func (l Lunar) ToDateString() string {
- if l.IsZero() {
+ if !l.IsValid() {
return ""
}
return l.ToYearString() + "年" + l.ToMonthString() + l.ToDayString()
}
-// IsZero reports whether is zero time.
-// 是否是农历零值时间
-func (l Lunar) IsZero() bool {
- if l.Error != nil {
- return true
- }
- if l.year == 0 || l.month == 0 || l.day == 0 {
+// IsValid reports whether is a valid lunar date.
+// 是否是有效的年份
+func (l Lunar) IsValid() bool {
+ if l.Year() >= MinValue().year && l.Year() <= MaxValue().year && l.month >= MinValue().month && l.month <= MaxValue().month && l.day >= MinValue().day && l.day <= MaxValue().day {
return true
}
return false
}
-// IsLeapYear reports whether is leap year.
+// IsLeapYear reports whether is a lunar leap year.
// 是否是农历闰年
func (l Lunar) IsLeapYear() bool {
if l.Error != nil {
@@ -355,7 +378,7 @@ func (l Lunar) IsLeapYear() bool {
return l.LeapMonth() != 0
}
-// IsLeapMonth reports whether is leap month.
+// IsLeapMonth reports whether is a lunar leap month.
// 是否是农历闰月
func (l Lunar) IsLeapMonth() bool {
if l.Error != nil {
@@ -364,7 +387,7 @@ func (l Lunar) IsLeapMonth() bool {
return l.month == l.LeapMonth()
}
-// IsRatYear reports whether is year of Rat.
+// IsRatYear reports whether is lunar year of Rat.
// 是否是鼠年
func (l Lunar) IsRatYear() bool {
if l.Error != nil {
@@ -376,7 +399,7 @@ func (l Lunar) IsRatYear() bool {
return false
}
-// IsOxYear reports whether is year of Ox.
+// IsOxYear reports whether is lunar year of Ox.
// 是否是牛年
func (l Lunar) IsOxYear() bool {
if l.Error != nil {
@@ -388,7 +411,7 @@ func (l Lunar) IsOxYear() bool {
return false
}
-// IsTigerYear reports whether is year of Tiger.
+// IsTigerYear reports whether is lunar year of Tiger.
// 是否是虎年
func (l Lunar) IsTigerYear() bool {
if l.Error != nil {
@@ -400,7 +423,7 @@ func (l Lunar) IsTigerYear() bool {
return false
}
-// IsRabbitYear reports whether is year of Rabbit.
+// IsRabbitYear reports whether is lunar year of Rabbit.
// 是否是兔年
func (l Lunar) IsRabbitYear() bool {
if l.Error != nil {
@@ -412,7 +435,7 @@ func (l Lunar) IsRabbitYear() bool {
return false
}
-// IsDragonYear reports whether is year of Dragon.
+// IsDragonYear reports whether is lunar year of Dragon.
// 是否是龙年
func (l Lunar) IsDragonYear() bool {
if l.Error != nil {
@@ -424,7 +447,7 @@ func (l Lunar) IsDragonYear() bool {
return false
}
-// IsSnakeYear reports whether is year of Snake.
+// IsSnakeYear reports whether is lunar year of Snake.
// 是否是蛇年
func (l Lunar) IsSnakeYear() bool {
if l.Error != nil {
@@ -436,7 +459,7 @@ func (l Lunar) IsSnakeYear() bool {
return false
}
-// IsHorseYear reports whether is year of Horse.
+// IsHorseYear reports whether is lunar year of Horse.
// 是否是马年
func (l Lunar) IsHorseYear() bool {
if l.Error != nil {
@@ -448,7 +471,7 @@ func (l Lunar) IsHorseYear() bool {
return false
}
-// IsGoatYear reports whether is year of Goat.
+// IsGoatYear reports whether is lunar year of Goat.
// 是否是羊年
func (l Lunar) IsGoatYear() bool {
if l.Error != nil {
@@ -460,7 +483,7 @@ func (l Lunar) IsGoatYear() bool {
return false
}
-// IsMonkeyYear reports whether is year of Monkey.
+// IsMonkeyYear reports whether is lunar year of Monkey.
// 是否是猴年
func (l Lunar) IsMonkeyYear() bool {
if l.Error != nil {
@@ -472,7 +495,7 @@ func (l Lunar) IsMonkeyYear() bool {
return false
}
-// IsRoosterYear reports whether is year of Rooster.
+// IsRoosterYear reports whether is lunar year of Rooster.
// 是否是鸡年
func (l Lunar) IsRoosterYear() bool {
if l.Error != nil {
@@ -484,7 +507,7 @@ func (l Lunar) IsRoosterYear() bool {
return false
}
-// IsDogYear reports whether is year of Dog.
+// IsDogYear reports whether is lunar year of Dog.
// 是否是狗年
func (l Lunar) IsDogYear() bool {
if l.Error != nil {
@@ -496,7 +519,7 @@ func (l Lunar) IsDogYear() bool {
return false
}
-// IsPigYear reports whether is year of Pig.
+// IsPigYear reports whether is lunar year of Pig.
// 是否是猪年
func (l Lunar) IsPigYear() bool {
if l.Error != nil {
@@ -509,7 +532,7 @@ func (l Lunar) IsPigYear() bool {
}
func (g Gregorian) diffInDays(t time.Time) int {
- return int(g.Time.Sub(t).Hours() / 24)
+ return int(g.Time.Truncate(time.Hour).Sub(t).Hours() / 24)
}
func (l Lunar) getOffsetInYear() int {
@@ -532,7 +555,7 @@ func (l Lunar) getOffsetInYear() int {
func (l Lunar) getOffsetInMonth() int {
clone, year, offset := l, 0, 0
- for year = minYear; year < l.year; year++ {
+ for year = MinValue().year; year < l.year; year++ {
clone.year = year
offset += clone.getDaysInYear()
}
@@ -542,7 +565,7 @@ func (l Lunar) getOffsetInMonth() int {
func (l Lunar) getDaysInYear() int {
var days = 348
for i := 0x8000; i > 0x8; i >>= 1 {
- if (years[l.year-minYear] & i) != 0 {
+ if (years[l.year-MinValue().year] & i) != 0 {
days++
}
}
@@ -550,7 +573,7 @@ func (l Lunar) getDaysInYear() int {
}
func (l Lunar) getDaysInMonth() int {
- if (years[l.year-minYear] & (0x10000 >> uint(l.month))) != 0 {
+ if (years[l.year-MinValue().year] & (0x10000 >> uint(l.month))) != 0 {
return 30
}
return 29
@@ -560,7 +583,7 @@ func (l Lunar) getDaysInLeapMonth() int {
if l.LeapMonth() == 0 {
return 0
}
- if years[l.year-minYear]&0x10000 != 0 {
+ if years[l.year-MinValue().year]&0x10000 != 0 {
return 30
}
return 29
diff --git a/vendor/github.com/dromara/carbon/v2/calendar/persian/README.cn.md b/vendor/github.com/dromara/carbon/v2/calendar/persian/README.cn.md
new file mode 100644
index 00000000..16c9486d
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/calendar/persian/README.cn.md
@@ -0,0 +1,74 @@
+# 波斯历(伊朗历)
+
+简体中文 | [English](README.md) | [日本語](README.jp.md)
+
+#### 用法示例
+
+##### 将 `公历` 转换成 `波斯历`
+
+```go
+// 获取波斯历年份
+carbon.Parse("2020-08-05 13:14:15").Persian().Year() // 1399
+// 获取波斯历月份
+carbon.Parse("2020-08-05 13:14:15").Persian().Month() // 5
+// 获取波斯历日期
+carbon.Parse("2020-08-05 13:14:15").Persian().Day() // 15
+// 获取波斯历小时
+carbon.Parse("2020-08-05 13:14:15").Persian().Hour() // 13
+// 获取波斯历分钟
+carbon.Parse("2020-08-05 13:14:15").Persian().Minute() // 14
+// 获取波斯历秒数
+carbon.Parse("2020-08-05 13:14:15").Persian().Second() // 15
+
+// 获取波斯历日期时间字符串
+carbon.Parse("2020-08-05 13:14:15").Persian().String() // 1399-05-15 13:14:15
+fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15").Persian()) // 1399-05-15 13:14:15
+
+// 获取波斯历月字符串
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString() // Mordad
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString("en") // Mordad
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString("fa") // مرداد
+
+// 获取简写波斯历月字符串
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString() // Mor
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString("en") // Mor
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString("fa") // مرد
+
+// 获取波斯历周字符串
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString() // Chaharshanbeh
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString("en") // Chaharshanbeh
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString("fa") // چهارشنبه
+
+// 获取简写波斯历周字符串
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString() // Cha
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString("en") // Cha
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString("fa") // د
+
+```
+
+##### 将 `波斯历` 转化成 `公历`
+
+```go
+carbon.CreateFromPersian(1, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).ToDateTimeString() // 1243-03-21 00:00:00
+carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).ToDateTimeString() // 9998-03-19 00:00:00
+```
+
+##### 日期判断
+```go
+// 是否是合法的波斯历日期
+carbon.CreateFromPersian(1, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(0, 0, 0, 0, 0, 0).IsValid() // false
+carbon.CreateFromPersian(2024, 0, 1, 0, 0, 0).IsValid() // false
+carbon.CreateFromPersian(2024, 1, 0, 0, 0, 0).IsValid() // false
+
+// 是否是波斯历闰年
+carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).IsLeapYear() // true
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).IsLeapYear() // true
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).IsLeapYear() // false
+carbon.CreateFromPersian(9999, 1, 1, 0, 0, 0).IsLeapYear() // false
+
+```
\ No newline at end of file
diff --git a/vendor/github.com/dromara/carbon/v2/calendar/persian/README.jp.md b/vendor/github.com/dromara/carbon/v2/calendar/persian/README.jp.md
new file mode 100644
index 00000000..c70a26ef
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/calendar/persian/README.jp.md
@@ -0,0 +1,73 @@
+# ペルシア暦(イラン暦)
+
+日本語 | [English](README.md) | [简体中文](README.cn.md)
+
+#### 使い方の例
+
+##### `西暦` を `ペルシャ暦` に変換
+
+```go
+// ペルシャ暦の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().Year() // 1399
+// ペルシャ暦月の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().Month() // 5
+// ペルシャ暦の取得日
+carbon.Parse("2020-08-05 13:14:15").Persian().Day() // 15
+// ペルシャ暦時間の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().Hour() // 13
+// ペルシャ暦分の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().Minute() // 14
+// ペルシャ暦秒の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().Second() // 15
+
+// ペルシャ暦日時文字列の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().String() // 1399-05-15 13:14:15
+fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15").Persian()) // 1399-05-15 13:14:15
+
+// ペルシア暦月文字列の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString() // Mordad
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString("en") // Mordad
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString("fa") // مرداد
+
+// 略語ペルシャ暦文字列の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString() // Mor
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString("en") // Mor
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString("fa") // مرد
+
+// ペルシャ暦週文字列の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString() // Chaharshanbeh
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString("en") // Chaharshanbeh
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString("fa") // چهارشنبه
+
+// 略語ペルシャ暦週文字列の取得
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString() // Cha
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString("en") // Cha
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString("fa") // د
+```
+
+##### ペルシャ暦を西暦に変換する
+
+```go
+carbon.CreateFromPersian(1, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).ToDateTimeString() // 1243-03-21 00:00:00
+carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).ToDateTimeString() // 9998-03-19 00:00:00
+```
+
+##### 日付判断
+```go
+// 合法的なペルシャ暦の日付かどうか
+carbon.CreateFromPersian(1, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(0, 0, 0, 0, 0, 0).IsValid() // false
+carbon.CreateFromPersian(2024, 0, 1, 0, 0, 0).IsValid() // false
+carbon.CreateFromPersian(2024, 1, 0, 0, 0, 0).IsValid() // false
+
+// ペルシア暦閏年かどうか
+carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).IsLeapYear() // true
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).IsLeapYear() // true
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).IsLeapYear() // false
+carbon.CreateFromPersian(9999, 1, 1, 0, 0, 0).IsLeapYear() // false
+
+```
\ No newline at end of file
diff --git a/vendor/github.com/dromara/carbon/v2/calendar/persian/README.md b/vendor/github.com/dromara/carbon/v2/calendar/persian/README.md
new file mode 100644
index 00000000..d5cf8255
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/calendar/persian/README.md
@@ -0,0 +1,74 @@
+# Persian(Jalaali) Calendar
+
+English | [简体中文](README.cn.md) | [日本語](README.jp.md)
+
+#### Usage and example
+
+##### Convert `Gregorian` calendar to `Persian` calendar
+
+```go
+// Get persian year
+carbon.Parse("2020-08-05 13:14:15").Persian().Year() // 1399
+// Get persian month
+carbon.Parse("2020-08-05 13:14:15").Persian().Month() // 5
+// Get persian day
+carbon.Parse("2020-08-05 13:14:15").Persian().Day() // 15
+// Get persian hour
+carbon.Parse("2020-08-05 13:14:15").Persian().Hour() // 13
+// Get persian minute
+carbon.Parse("2020-08-05 13:14:15").Persian().Minute() // 14
+// Get persian second
+carbon.Parse("2020-08-05 13:14:15").Persian().Second() // 15
+
+// Get persian date and time string
+carbon.Parse("2020-08-05 13:14:15").Persian().String() // 1399-05-15 13:14:15
+fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15").Persian()) // 1399-05-15 13:14:15
+
+// Get persian month as string
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString() // Mordad
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString("en") // Mordad
+carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString("fa") // مرداد
+
+// Get persian short month as string
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString() // Mor
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString("en") // Mor
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortMonthString("fa") // مرد
+
+// Get persian week as string
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString() // Chaharshanbeh
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString("en") // Chaharshanbeh
+carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString("fa") // چهارشنبه
+
+// Get persian short week as string
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString() // Cha
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString("en") // Cha
+carbon.Parse("2020-08-05 13:14:15").Persian().ToShortWeekString("fa") // د
+
+```
+
+##### Convert `Persian` calendar to `Gregorian` calendar
+
+```go
+carbon.CreateFromPersian(1, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).ToDateTimeString() // 1243-03-21 00:00:00
+carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).ToDateTimeString() // 9998-03-19 00:00:00
+```
+
+##### Comparison
+```go
+// Whether is a valid persian date
+carbon.CreateFromPersian(1, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).IsValid() // true
+carbon.CreateFromPersian(0, 0, 0, 0, 0, 0).IsValid() // false
+carbon.CreateFromPersian(2024, 0, 1, 0, 0, 0).IsValid() // false
+carbon.CreateFromPersian(2024, 1, 0, 0, 0, 0).IsValid() // false
+
+// Whether is a persian leap year
+carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).IsLeapYear() // true
+carbon.CreateFromPersian(9377, 1, 1, 0, 0, 0).IsLeapYear() // true
+carbon.CreateFromPersian(622, 1, 1, 0, 0, 0).IsLeapYear() // false
+carbon.CreateFromPersian(9999, 1, 1, 0, 0, 0).IsLeapYear() // false
+
+```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/persian/persian.go b/vendor/github.com/dromara/carbon/v2/calendar/persian/persian.go
similarity index 55%
rename from vendor/github.com/golang-module/carbon/v2/calendar/persian/persian.go
rename to vendor/github.com/dromara/carbon/v2/calendar/persian/persian.go
index 5ef79f28..8b2b7ae0 100644
--- a/vendor/github.com/golang-module/carbon/v2/calendar/persian/persian.go
+++ b/vendor/github.com/dromara/carbon/v2/calendar/persian/persian.go
@@ -6,17 +6,25 @@ import (
"math"
"time"
- "github.com/golang-module/carbon/v2/calendar"
- "github.com/golang-module/carbon/v2/calendar/julian"
+ "github.com/dromara/carbon/v2/calendar"
+ "github.com/dromara/carbon/v2/calendar/julian"
)
var (
- minYear = 1097
- months = []string{"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"}
- weeks = []string{"یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}
+ EnMonths = []string{"Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand"}
+ ShortEnMonths = []string{"Far", "Ord", "Kho", "Tir", "Mor", "Sha", "Meh", "Aba", "Aza", "Dey", "Bah", "Esf"}
- invalidYearError = func() error {
- return fmt.Errorf("invalid year, cannot exceed 1079")
+ FaMonths = []string{"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"}
+ ShortFaMonths = []string{"فرو", "ارد", "خرد", "تیر", "مرد", "شهر", "مهر", "آبا", "آذر", "دی", "بهم", "اسف"}
+
+ EnWeeks = []string{"Yekshanbeh", "Doshanbeh", "Seshanbeh", "Chaharshanbeh", "Panjshanbeh", "Jomeh", "Shanbeh"}
+ ShortEnWeeks = []string{"Yek", "Dos", "Ses", "Cha", "Pan", "Jom", "Sha"}
+
+ FaWeeks = []string{"نجشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}
+ ShortFaWeeks = []string{"پ", "چ", "س", "د", "ی", "ش", "ج"}
+
+ InvalidDateError = func() error {
+ return fmt.Errorf("invalid persian date, please make sure the date is valid")
}
)
@@ -33,6 +41,32 @@ type Persian struct {
Error error
}
+// MaxValue returns a Persian instance for the greatest supported date.
+// 返回 Persian 的最大值
+func MaxValue() Persian {
+ return Persian{
+ year: 9377,
+ month: 12,
+ day: 31,
+ hour: 23,
+ minute: 59,
+ second: 59,
+ }
+}
+
+// MinValue returns a Persian instance for the lowest supported date.
+// 返回 Persian 的最小值
+func MinValue() Persian {
+ return Persian{
+ year: 1,
+ month: 1,
+ day: 1,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ }
+}
+
// FromGregorian creates a Gregorian instance from time.Time.
// 从标准 time.Time 创建 Gregorian 实例
func FromGregorian(t time.Time) (g Gregorian) {
@@ -48,27 +82,23 @@ func FromGregorian(t time.Time) (g Gregorian) {
func FromPersian(year, month, day, hour, minute, second int) (p Persian) {
p.year, p.month, p.day = year, month, day
p.hour, p.minute, p.second = hour, minute, second
- return p
+ if !p.IsValid() {
+ p.Error = InvalidDateError()
+ return
+ }
+ return
}
// ToPersian converts Gregorian instance to Persian instance.
// 将 Gregorian 实例转化为 Persian 实例
func (g Gregorian) ToPersian() (p Persian) {
- if g.IsZero() {
- return
- }
p.hour, p.minute, p.second = g.Hour(), g.Minute(), g.Second()
- if g.Year() < minYear {
- p.Error = invalidYearError()
- return
- }
gjdn := getGregorianJdn(g.Year(), g.Month(), g.Day())
pjdn := getPersianJdn(475, 1, 1)
diff := gjdn - pjdn
div := diff / 1029983
mod := diff % 1029983
-
p.year = (2134*mod/366+2816*(mod%366)+2815)/1028522 + mod/366 + 1 + 2820*div + 474
pjdn = getPersianJdn(p.year, 1, 1)
fjdn := float64(gjdn - pjdn + 1)
@@ -79,13 +109,17 @@ func (g Gregorian) ToPersian() (p Persian) {
}
pjdn = getPersianJdn(p.year, p.month, 1)
p.day = gjdn - pjdn + 1
+ if !p.IsValid() {
+ p.Error = InvalidDateError()
+ return
+ }
return
}
// ToGregorian converts Persian instance to Gregorian instance.
// 将 Persian 实例转化为 Gregorian 实例
func (p Persian) ToGregorian() (g Gregorian) {
- if p.IsZero() {
+ if !p.IsValid() {
return
}
jdn := getPersianJdn(p.year, p.month, p.day)
@@ -162,7 +196,7 @@ func (p Persian) Second() int {
// String implements Stringer interface and outputs a string in YYYY-MM-DD HH::ii::ss format like "1402-11-11 00:00:00".
// 实现 Stringer 接口, 输出 YYYY-MM-DD HH::ii::ss 格式字符串,如 "1402-11-11 00:00:00"
func (p Persian) String() string {
- if p.IsZero() {
+ if !p.IsValid() {
return ""
}
return fmt.Sprintf("%d-%02d-%02d %02d:%02d:%02d", p.year, p.month, p.day, p.hour, p.minute, p.second)
@@ -170,38 +204,93 @@ func (p Persian) String() string {
// ToMonthString outputs a string in persian month format like "فروردین".
// 获取完整月份字符串,如 "فروردین"
-func (p Persian) ToMonthString() (month string) {
- if p.IsZero() {
+func (p Persian) ToMonthString(locale ...string) (month string) {
+ if !p.IsValid() {
return ""
}
- return months[p.month-1]
+ loc := "en"
+ if len(locale) > 0 {
+ loc = locale[0]
+ }
+ switch loc {
+ case "en":
+ return EnMonths[p.month-1]
+ case "fa":
+ return FaMonths[p.month-1]
+ }
+ return ""
+}
+
+// ToShortMonthString outputs a short string in persian month format like "فروردین".
+// 获取缩写月份字符串,如 "فروردین"
+func (p Persian) ToShortMonthString(locale ...string) (month string) {
+ if !p.IsValid() {
+ return ""
+ }
+ loc := "en"
+ if len(locale) > 0 {
+ loc = locale[0]
+ }
+ switch loc {
+ case "en":
+ return ShortEnMonths[p.month-1]
+ case "fa":
+ return ShortFaMonths[p.month-1]
+ }
+ return ""
}
// ToWeekString outputs a string in week layout like "چهارشنبه".
// 输出完整星期字符串,如 "چهارشنبه"
-func (p Persian) ToWeekString() (month string) {
- if p.IsZero() {
+func (p Persian) ToWeekString(locale ...string) (month string) {
+ if !p.IsValid() {
return ""
}
- return weeks[p.ToGregorian().Week()]
+ loc := "en"
+ if len(locale) > 0 {
+ loc = locale[0]
+ }
+ switch loc {
+ case "en":
+ return EnWeeks[p.ToGregorian().Week()]
+ case "fa":
+ return FaWeeks[p.ToGregorian().Week()]
+ }
+ return ""
}
-// IsZero reports whether is zero time.
-// 是否是零值时间
-func (p Persian) IsZero() bool {
- if p.Error != nil {
- return true
+// ToShortWeekString outputs a short string in week layout like "چهارشنبه".
+// 输出缩写星期字符串,如 "چهارشنبه"
+func (p Persian) ToShortWeekString(locale ...string) (month string) {
+ if !p.IsValid() {
+ return ""
}
- if p.year == 0 || p.month == 0 || p.day == 0 {
+ loc := "en"
+ if len(locale) > 0 {
+ loc = locale[0]
+ }
+ switch loc {
+ case "en":
+ return ShortEnWeeks[p.ToGregorian().Week()]
+ case "fa":
+ return ShortFaWeeks[p.ToGregorian().Week()]
+ }
+ return ""
+}
+
+// IsValid reports whether is a valid persian date.
+// 是否是有效的日期
+func (p Persian) IsValid() bool {
+ if p.Year() >= MinValue().year && p.Year() <= MaxValue().year && p.month >= MinValue().month && p.month <= MaxValue().month && p.day >= MinValue().day && p.day <= MaxValue().day {
return true
}
return false
}
-// IsLeapYear reports whether is a leap year.
+// IsLeapYear reports whether is a persian leap year.
// 是否是闰年
func (p Persian) IsLeapYear() bool {
- if p.IsZero() {
+ if !p.IsValid() {
return false
}
return (25*p.year+11)%33 < 8
diff --git a/vendor/github.com/golang-module/carbon/v2/carbon.go b/vendor/github.com/dromara/carbon/v2/carbon.go
similarity index 67%
rename from vendor/github.com/golang-module/carbon/v2/carbon.go
rename to vendor/github.com/dromara/carbon/v2/carbon.go
index a3db620a..321e0842 100644
--- a/vendor/github.com/golang-module/carbon/v2/carbon.go
+++ b/vendor/github.com/dromara/carbon/v2/carbon.go
@@ -1,9 +1,9 @@
// @Package carbon
// @Description a simple, semantic and developer-friendly golang package for datetime
-// @Page github.com/golang-module/carbon
+// @Page github.com/dromara/carbon
// @Developer gouguoyin
-// @Blog www.gouguoyin.cn
-// @Email contact@gouguoyin.cn
+// @Blog www.gouguoyin.com
+// @Email 245629560@qq.com
// Package carbon is a simple, semantic and developer-friendly golang package for datetime.
package carbon
@@ -14,7 +14,7 @@ import (
// Version current version
// 当前版本号
-const Version = "2.3.10"
+const Version = "2.5.2"
// timezone constants
// 时区常量
@@ -271,8 +271,8 @@ const (
type Carbon struct {
time time.Time
testNow int64 // nanosecond timestamp of test now time
+ layout string
weekStartsAt time.Weekday
- tag *tag
loc *time.Location
lang *Language
Error error
@@ -286,5 +286,198 @@ func NewCarbon() Carbon {
if weekday, ok := weekdays[defaultWeekStartsAt]; ok {
c.weekStartsAt = weekday
}
+ c.layout = defaultLayout
return c
}
+
+// DateTime defines a DateTime struct.
+// 定义 DateTime 结构体
+type DateTime struct {
+ Carbon
+}
+
+// NewDateTime returns a new DateTime instance.
+// 初始化 DateTime 结构体
+func NewDateTime(carbon Carbon) DateTime {
+ return DateTime{Carbon: carbon}
+}
+
+// DateTimeMilli defines a DateTimeMilli struct.
+// 定义 DateTimeMilli 结构体
+type DateTimeMilli struct {
+ Carbon
+}
+
+// NewDateTimeMilli returns a new DateTimeMilli instance.
+// 初始化 DateTimeMilli 结构体
+func NewDateTimeMilli(carbon Carbon) DateTimeMilli {
+ return DateTimeMilli{Carbon: carbon}
+}
+
+// DateTimeMicro defines a DateTimeMicro struct.
+// 定义 DateTimeMicro 结构体
+type DateTimeMicro struct {
+ Carbon
+}
+
+// NewDateTimeMicro returns a new DateTimeMicro instance.
+// 初始化 DateTimeMicro 结构体
+func NewDateTimeMicro(carbon Carbon) DateTimeMicro {
+ return DateTimeMicro{Carbon: carbon}
+}
+
+// DateTimeNano defines a DateTimeNano struct.
+// 定义 DateTimeNano 结构体
+type DateTimeNano struct {
+ Carbon
+}
+
+// NewDateTimeNano returns a new DateTimeNano instance.
+// 初始化 DateTimeNano 结构体
+func NewDateTimeNano(carbon Carbon) DateTimeNano {
+ return DateTimeNano{Carbon: carbon}
+}
+
+// Date defines a Date struct.
+// 定义 Date 结构体
+type Date struct {
+ Carbon
+}
+
+// NewDate returns a new Date instance.
+// 初始化 Date 结构体
+func NewDate(carbon Carbon) Date {
+ return Date{Carbon: carbon}
+}
+
+// DateMilli defines a DateMilli struct.
+// 定义 DateMilli 结构体
+type DateMilli struct {
+ Carbon
+}
+
+// NewDateMilli returns a new DateMilli instance.
+// 初始化 DateMilli 结构体
+func NewDateMilli(carbon Carbon) DateMilli {
+ return DateMilli{Carbon: carbon}
+}
+
+// DateMicro defines a DateMicro struct.
+// 定义 DateMicro 结构体
+type DateMicro struct {
+ Carbon
+}
+
+// NewDateMicro returns a new DateMicro instance.
+// 初始化 DateMicro 结构体
+func NewDateMicro(carbon Carbon) DateMicro {
+ return DateMicro{Carbon: carbon}
+}
+
+// DateNano defines a DateNano struct.
+// 定义 DateNano 结构体
+type DateNano struct {
+ Carbon
+}
+
+// NewDateNano returns a new DateNano instance.
+// 初始化 DateNano 结构体
+func NewDateNano(carbon Carbon) DateNano {
+ return DateNano{Carbon: carbon}
+}
+
+// Time defines a Time struct.
+// 定义 Time 结构体
+type Time struct {
+ Carbon
+}
+
+// NewTime returns a new Time instance.
+// 初始化 Time 结构体
+func NewTime(carbon Carbon) Time {
+ return Time{Carbon: carbon}
+}
+
+// TimeMilli defines a TimeMilli struct.
+// 定义 TimeMilli 结构体
+type TimeMilli struct {
+ Carbon
+}
+
+// NewTimeMilli returns a new TimeMilli instance.
+// 初始化 TimeMilli 结构体
+func NewTimeMilli(carbon Carbon) TimeMilli {
+ return TimeMilli{Carbon: carbon}
+}
+
+// TimeMicro defines a TimeMicro struct.
+// 定义 TimeMicro 结构体
+type TimeMicro struct {
+ Carbon
+}
+
+// NewTimeMicro returns a new TimeMicro instance.
+// 初始化 TimeMicro 结构体
+func NewTimeMicro(carbon Carbon) TimeMicro {
+ return TimeMicro{Carbon: carbon}
+}
+
+// TimeNano defines a TimeNano struct.
+// 定义 TimeNano 结构体
+type TimeNano struct {
+ Carbon
+}
+
+// NewTimeNano returns a new TimeNano instance.
+// 初始化 TimeNano 结构体
+func NewTimeNano(carbon Carbon) TimeNano {
+ return TimeNano{Carbon: carbon}
+}
+
+// Timestamp defines a Timestamp struct.
+// 定义 Timestamp 结构体
+type Timestamp struct {
+ Carbon
+}
+
+// NewTimestamp returns a new Timestamp instance.
+// 初始化 Timestamp 结构体
+func NewTimestamp(carbon Carbon) Timestamp {
+ return Timestamp{Carbon: carbon}
+}
+
+// TimestampMilli defines a TimestampMilli struct.
+// 定义 TimestampMilli 结构体
+type TimestampMilli struct {
+ Carbon
+}
+
+// NewTimestampMilli returns a new TimestampMilli instance.
+// 初始化 TimestampMilli 结构体
+func NewTimestampMilli(carbon Carbon) TimestampMilli {
+ return TimestampMilli{Carbon: carbon}
+}
+
+// TimestampMicro defines a TimestampMicro struct.
+// 定义 TimestampMicro 结构体
+type TimestampMicro struct {
+ Carbon
+}
+
+// NewTimestampMicro returns a new TimestampMicro instance.
+// 初始化 TimestampMicro 结构体
+func NewTimestampMicro(carbon Carbon) TimestampMicro {
+ return TimestampMicro{Carbon: carbon}
+}
+
+// TimestampNano defines a TimestampNano struct.
+// 定义 TimestampNano 结构体
+type TimestampNano struct {
+ Carbon
+}
+
+// NewTimestampNano returns a new TimestampNano instance.
+// 初始化 TimestampNano 结构体
+func NewTimestampNano(carbon Carbon) TimestampNano {
+ return TimestampNano{Carbon: carbon}
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/comparer.go b/vendor/github.com/dromara/carbon/v2/comparer.go
similarity index 84%
rename from vendor/github.com/golang-module/carbon/v2/comparer.go
rename to vendor/github.com/dromara/carbon/v2/comparer.go
index b7130573..1b7bbffb 100644
--- a/vendor/github.com/golang-module/carbon/v2/comparer.go
+++ b/vendor/github.com/dromara/carbon/v2/comparer.go
@@ -10,8 +10,8 @@ func (c Carbon) IsDST() bool {
return c.time.IsDST()
}
-// IsZero reports whether is zero time.
-// 是否是零值时间
+// IsZero reports whether is zero time(0001-01-01 00:00:00 +0000 UTC).
+// 是否是零值时间(0001-01-01 00:00:00 +0000 UTC)
func (c Carbon) IsZero() bool {
return c.time.IsZero()
}
@@ -19,7 +19,10 @@ func (c Carbon) IsZero() bool {
// IsValid reports whether is valid time.
// 是否是有效时间
func (c Carbon) IsValid() bool {
- if c.Error == nil && !c.IsZero() {
+ if c.IsZero() {
+ return false
+ }
+ if c.Year() >= MinValue().Year() && c.Year() <= MaxValue().Year() && c.Month() > 0 && c.Day() > 0 {
return true
}
return false
@@ -46,7 +49,7 @@ func (c Carbon) IsPM() bool {
// IsNow reports whether is now time.
// 是否是当前时间
func (c Carbon) IsNow() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Timestamp() == c.Now().Timestamp()
@@ -55,7 +58,7 @@ func (c Carbon) IsNow() bool {
// IsFuture reports whether is future time.
// 是否是未来时间
func (c Carbon) IsFuture() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Timestamp() > c.Now().Timestamp()
@@ -64,7 +67,7 @@ func (c Carbon) IsFuture() bool {
// IsPast reports whether is past time.
// 是否是过去时间
func (c Carbon) IsPast() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Timestamp() < c.Now().Timestamp()
@@ -73,7 +76,7 @@ func (c Carbon) IsPast() bool {
// IsLeapYear reports whether is a leap year.
// 是否是闰年
func (c Carbon) IsLeapYear() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
year := c.Year()
@@ -86,7 +89,7 @@ func (c Carbon) IsLeapYear() bool {
// IsLongYear reports whether is a long year, see https://en.wikipedia.org/wiki/ISO_8601#Week_dates.
// 是否是长年
func (c Carbon) IsLongYear() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
_, w := time.Date(c.Year(), 12, 31, 0, 0, 0, 0, c.loc).ISOWeek()
@@ -96,7 +99,7 @@ func (c Carbon) IsLongYear() bool {
// IsJanuary reports whether is January.
// 是否是一月
func (c Carbon) IsJanuary() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.January)
@@ -105,7 +108,7 @@ func (c Carbon) IsJanuary() bool {
// IsFebruary reports whether is February.
// 是否是二月
func (c Carbon) IsFebruary() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.February)
@@ -114,7 +117,7 @@ func (c Carbon) IsFebruary() bool {
// IsMarch reports whether is March.
// 是否是三月
func (c Carbon) IsMarch() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.March)
@@ -123,7 +126,7 @@ func (c Carbon) IsMarch() bool {
// IsApril reports whether is April.
// 是否是四月
func (c Carbon) IsApril() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.April)
@@ -132,7 +135,7 @@ func (c Carbon) IsApril() bool {
// IsMay reports whether is May.
// 是否是五月
func (c Carbon) IsMay() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.May)
@@ -141,7 +144,7 @@ func (c Carbon) IsMay() bool {
// IsJune reports whether is June.
// 是否是六月
func (c Carbon) IsJune() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.June)
@@ -150,7 +153,7 @@ func (c Carbon) IsJune() bool {
// IsJuly reports whether is July.
// 是否是七月
func (c Carbon) IsJuly() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.July)
@@ -159,7 +162,7 @@ func (c Carbon) IsJuly() bool {
// IsAugust reports whether is August.
// 是否是八月
func (c Carbon) IsAugust() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.August)
@@ -168,7 +171,7 @@ func (c Carbon) IsAugust() bool {
// IsSeptember reports whether is September.
// 是否是九月
func (c Carbon) IsSeptember() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.September)
@@ -177,7 +180,7 @@ func (c Carbon) IsSeptember() bool {
// IsOctober reports whether is October.
// 是否是十月
func (c Carbon) IsOctober() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.October)
@@ -186,7 +189,7 @@ func (c Carbon) IsOctober() bool {
// IsNovember reports whether is November.
// 是否是十一月
func (c Carbon) IsNovember() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.November)
@@ -195,7 +198,7 @@ func (c Carbon) IsNovember() bool {
// IsDecember reports whether is December.
// 是否是十二月
func (c Carbon) IsDecember() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.Month() == int(time.December)
@@ -204,7 +207,7 @@ func (c Carbon) IsDecember() bool {
// IsMonday reports whether is Monday.
// 是否是周一
func (c Carbon) IsMonday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Monday
@@ -213,7 +216,7 @@ func (c Carbon) IsMonday() bool {
// IsTuesday reports whether is Tuesday.
// 是否是周二
func (c Carbon) IsTuesday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Tuesday
@@ -222,7 +225,7 @@ func (c Carbon) IsTuesday() bool {
// IsWednesday reports whether is Wednesday.
// 是否是周三
func (c Carbon) IsWednesday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Wednesday
@@ -231,7 +234,7 @@ func (c Carbon) IsWednesday() bool {
// IsThursday reports whether is Thursday.
// 是否是周四
func (c Carbon) IsThursday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Thursday
@@ -240,7 +243,7 @@ func (c Carbon) IsThursday() bool {
// IsFriday reports whether is Friday.
// 是否是周五
func (c Carbon) IsFriday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Friday
@@ -249,7 +252,7 @@ func (c Carbon) IsFriday() bool {
// IsSaturday reports whether is Saturday.
// 是否是周六
func (c Carbon) IsSaturday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Saturday
@@ -258,7 +261,7 @@ func (c Carbon) IsSaturday() bool {
// IsSunday reports whether is Sunday.
// 是否是周日
func (c Carbon) IsSunday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.StdTime().Weekday() == time.Sunday
@@ -267,7 +270,7 @@ func (c Carbon) IsSunday() bool {
// IsWeekday reports whether is weekday.
// 是否是工作日
func (c Carbon) IsWeekday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return !c.IsSaturday() && !c.IsSunday()
@@ -276,7 +279,7 @@ func (c Carbon) IsWeekday() bool {
// IsWeekend reports whether is weekend.
// 是否是周末
func (c Carbon) IsWeekend() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.IsSaturday() || c.IsSunday()
@@ -285,7 +288,7 @@ func (c Carbon) IsWeekend() bool {
// IsYesterday reports whether is yesterday.
// 是否是昨天
func (c Carbon) IsYesterday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.ToDateString() == Yesterday().ToDateString()
@@ -294,7 +297,7 @@ func (c Carbon) IsYesterday() bool {
// IsToday reports whether is today.
// 是否是今天
func (c Carbon) IsToday() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.ToDateString() == Now().ToDateString()
@@ -303,7 +306,7 @@ func (c Carbon) IsToday() bool {
// IsTomorrow reports whether is tomorrow.
// 是否是明天
func (c Carbon) IsTomorrow() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
return c.ToDateString() == Tomorrow().ToDateString()
@@ -312,7 +315,7 @@ func (c Carbon) IsTomorrow() bool {
// IsSameCentury reports whether is same century.
// 是否是同一世纪
func (c Carbon) IsSameCentury(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Century() == t.Century()
@@ -321,7 +324,7 @@ func (c Carbon) IsSameCentury(t Carbon) bool {
// IsSameDecade reports whether is same decade.
// 是否是同一年代
func (c Carbon) IsSameDecade(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Decade() == t.Decade()
@@ -330,7 +333,7 @@ func (c Carbon) IsSameDecade(t Carbon) bool {
// IsSameYear reports whether is same year.
// 是否是同一年
func (c Carbon) IsSameYear(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Year() == t.Year()
@@ -339,7 +342,7 @@ func (c Carbon) IsSameYear(t Carbon) bool {
// IsSameQuarter reports whether is same quarter.
// 是否是同一季节
func (c Carbon) IsSameQuarter(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Quarter() == t.Quarter()
@@ -348,7 +351,7 @@ func (c Carbon) IsSameQuarter(t Carbon) bool {
// IsSameMonth reports whether is same month.
// 是否是同一月
func (c Carbon) IsSameMonth(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Format("Ym") == t.Format("Ym")
@@ -357,7 +360,7 @@ func (c Carbon) IsSameMonth(t Carbon) bool {
// IsSameDay reports whether is same day.
// 是否是同一天
func (c Carbon) IsSameDay(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Format("Ymd") == t.Format("Ymd")
@@ -366,7 +369,7 @@ func (c Carbon) IsSameDay(t Carbon) bool {
// IsSameHour reports whether is same hour.
// 是否是同一小时
func (c Carbon) IsSameHour(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Format("YmdH") == t.Format("YmdH")
@@ -375,7 +378,7 @@ func (c Carbon) IsSameHour(t Carbon) bool {
// IsSameMinute reports whether is same minute.
// 是否是同一分钟
func (c Carbon) IsSameMinute(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Format("YmdHi") == t.Format("YmdHi")
@@ -384,7 +387,7 @@ func (c Carbon) IsSameMinute(t Carbon) bool {
// IsSameSecond reports whether is same second.
// 是否是同一秒
func (c Carbon) IsSameSecond(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Format("YmdHis") == t.Format("YmdHis")
@@ -394,7 +397,7 @@ func (c Carbon) IsSameSecond(t Carbon) bool {
// Compare compares by an operator.
// 时间比较
func (c Carbon) Compare(operator string, t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
switch operator {
@@ -417,7 +420,7 @@ func (c Carbon) Compare(operator string, t Carbon) bool {
// Gt reports whether greater than.
// 是否大于
func (c Carbon) Gt(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.time.After(t.time)
@@ -426,7 +429,7 @@ func (c Carbon) Gt(t Carbon) bool {
// Lt reports whether less than.
// 是否小于
func (c Carbon) Lt(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.time.Before(t.time)
@@ -435,7 +438,7 @@ func (c Carbon) Lt(t Carbon) bool {
// Eq reports whether equal.
// 是否等于
func (c Carbon) Eq(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.time.Equal(t.time)
@@ -450,7 +453,7 @@ func (c Carbon) Ne(t Carbon) bool {
// Gte reports whether greater than or equal.
// 是否大于等于
func (c Carbon) Gte(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Gt(t) || c.Eq(t)
@@ -459,7 +462,7 @@ func (c Carbon) Gte(t Carbon) bool {
// Lte reports whether less than or equal.
// 是否小于等于
func (c Carbon) Lte(t Carbon) bool {
- if c.IsInvalid() || t.IsInvalid() {
+ if c.Error != nil || t.Error != nil {
return false
}
return c.Lt(t) || c.Eq(t)
@@ -468,7 +471,7 @@ func (c Carbon) Lte(t Carbon) bool {
// Between reports whether between two times, excluded the start and end time.
// 是否在两个时间之间(不包括这两个时间)
func (c Carbon) Between(start Carbon, end Carbon) bool {
- if c.IsInvalid() || start.IsInvalid() || end.IsInvalid() {
+ if c.Error != nil || start.Error != nil || end.Error != nil {
return false
}
if c.Gt(start) && c.Lt(end) {
@@ -480,7 +483,7 @@ func (c Carbon) Between(start Carbon, end Carbon) bool {
// BetweenIncludedStart reports whether between two times, included the start time.
// 是否在两个时间之间(包括开始时间)
func (c Carbon) BetweenIncludedStart(start Carbon, end Carbon) bool {
- if c.IsInvalid() || start.IsInvalid() || end.IsInvalid() {
+ if c.Error != nil || start.Error != nil || end.Error != nil {
return false
}
if c.Gte(start) && c.Lt(end) {
@@ -492,7 +495,7 @@ func (c Carbon) BetweenIncludedStart(start Carbon, end Carbon) bool {
// BetweenIncludedEnd reports whether between two times, included the end time.
// 是否在两个时间之间(包括结束时间)
func (c Carbon) BetweenIncludedEnd(start Carbon, end Carbon) bool {
- if c.IsInvalid() || start.IsInvalid() || end.IsInvalid() {
+ if c.Error != nil || start.Error != nil || end.Error != nil {
return false
}
if c.Gt(start) && c.Lte(end) {
@@ -504,7 +507,7 @@ func (c Carbon) BetweenIncludedEnd(start Carbon, end Carbon) bool {
// BetweenIncludedBoth reports whether between two times, included the start and end time.
// 是否在两个时间之间(包括这两个时间)
func (c Carbon) BetweenIncludedBoth(start Carbon, end Carbon) bool {
- if c.IsInvalid() || start.IsInvalid() || end.IsInvalid() {
+ if c.Error != nil || start.Error != nil || end.Error != nil {
return false
}
if c.Gte(start) && c.Lte(end) {
diff --git a/vendor/github.com/golang-module/carbon/v2/constellation.go b/vendor/github.com/dromara/carbon/v2/constellation.go
similarity index 98%
rename from vendor/github.com/golang-module/carbon/v2/constellation.go
rename to vendor/github.com/dromara/carbon/v2/constellation.go
index 005b32e1..5bfba2d9 100644
--- a/vendor/github.com/golang-module/carbon/v2/constellation.go
+++ b/vendor/github.com/dromara/carbon/v2/constellation.go
@@ -42,8 +42,8 @@ func (c Carbon) Constellation() string {
index = i
}
}
- c.lang.rw.Lock()
- defer c.lang.rw.Unlock()
+ c.lang.rw.RLock()
+ defer c.lang.rw.RUnlock()
if resources, ok := c.lang.resources["constellations"]; ok {
slice := strings.Split(resources, "|")
if len(slice) == MonthsPerYear {
diff --git a/vendor/github.com/golang-module/carbon/v2/creator.go b/vendor/github.com/dromara/carbon/v2/creator.go
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/creator.go
rename to vendor/github.com/dromara/carbon/v2/creator.go
diff --git a/vendor/github.com/dromara/carbon/v2/database.go b/vendor/github.com/dromara/carbon/v2/database.go
new file mode 100644
index 00000000..3069eb73
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/database.go
@@ -0,0 +1,890 @@
+package carbon
+
+import (
+ "bytes"
+ "database/sql/driver"
+ "errors"
+ "fmt"
+ "strconv"
+ "time"
+)
+
+// returns a failed scan error.
+// 失败的扫描错误
+var failedScanError = func(src interface{}) error {
+ return errors.New(fmt.Sprintf("failed to scan value: %v", src))
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (c *Carbon) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *c = Parse(string(v))
+ case string:
+ *c = Parse(v)
+ case time.Time:
+ *c = CreateFromStdTime(v)
+ }
+ if c.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (c Carbon) Value() (driver.Value, error) {
+ if c.IsZero() {
+ return nil, nil
+ }
+ return c.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for Carbon struct.
+// 实现 json.Marshaler 接口
+func (c Carbon) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, c.Layout(c.layout))), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for Carbon struct.
+// 实现 json.Unmarshaler 接口
+func (c *Carbon) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ *c = ParseByLayout(value, c.layout)
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateTime) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateTime(Parse(string(v)))
+ case string:
+ *t = NewDateTime(Parse(v))
+ case time.Time:
+ *t = NewDateTime(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateTime) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateTime struct.
+// 实现 MarshalJSON 接口
+func (t DateTime) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateTime struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateTime) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateTimeLayout)
+ if c.Error == nil {
+ *t = NewDateTime(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateTimeMilli) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateTimeMilli(Parse(string(v)))
+ case string:
+ *t = NewDateTimeMilli(Parse(v))
+ case time.Time:
+ *t = NewDateTimeMilli(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateTimeMilli) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateTimeMilli struct.
+// 实现 MarshalJSON 接口
+func (t DateTimeMilli) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeMilliString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateTimeMilli struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateTimeMilli) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateTimeMilliLayout)
+ if c.Error == nil {
+ *t = NewDateTimeMilli(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateTimeMicro) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateTimeMicro(Parse(string(v)))
+ case string:
+ *t = NewDateTimeMicro(Parse(v))
+ case time.Time:
+ *t = NewDateTimeMicro(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateTimeMicro) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateTimeMicro struct.
+// 实现 MarshalJSON 接口
+func (t DateTimeMicro) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeMicroString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateTimeMicro struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateTimeMicro) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateTimeMicroLayout)
+ if c.Error == nil {
+ *t = NewDateTimeMicro(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateTimeNano) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateTimeNano(Parse(string(v)))
+ case string:
+ *t = NewDateTimeNano(Parse(v))
+ case time.Time:
+ *t = NewDateTimeNano(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateTimeNano) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateTimeNano struct.
+// 实现 MarshalJSON 接口
+func (t DateTimeNano) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateTimeNanoString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateTimeNano struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateTimeNano) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateTimeNanoLayout)
+ if c.Error == nil {
+ *t = NewDateTimeNano(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *Date) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDate(Parse(string(v)))
+ case string:
+ *t = NewDate(Parse(v))
+ case time.Time:
+ *t = NewDate(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *Date) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for Date struct.
+// 实现 MarshalJSON 接口
+func (t Date) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for Date struct.
+// 实现 UnmarshalJSON 接口
+func (t *Date) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateLayout)
+ if c.Error == nil {
+ *t = NewDate(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateMilli) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateMilli(Parse(string(v)))
+ case string:
+ *t = NewDateMilli(Parse(v))
+ case time.Time:
+ *t = NewDateMilli(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateMilli) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateMilli struct.
+// 实现 MarshalJSON 接口
+func (t DateMilli) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateMilliString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateMilli struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateMilli) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateMilliLayout)
+ if c.Error == nil {
+ *t = NewDateMilli(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateMicro) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateMicro(Parse(string(v)))
+ case string:
+ *t = NewDateMicro(Parse(v))
+ case time.Time:
+ *t = NewDateMicro(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateMicro) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateMicro struct.
+// 实现 MarshalJSON 接口
+func (t DateMicro) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateMicroString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateMicro struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateMicro) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateMicroLayout)
+ if c.Error == nil {
+ *t = NewDateMicro(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *DateNano) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewDateNano(Parse(string(v)))
+ case string:
+ *t = NewDateNano(Parse(v))
+ case time.Time:
+ *t = NewDateNano(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *DateNano) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for DateNano struct.
+// 实现 MarshalJSON 接口
+func (t DateNano) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToDateNanoString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for DateNano struct.
+// 实现 UnmarshalJSON 接口
+func (t *DateNano) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ c := ParseByLayout(value, DateNanoLayout)
+ if c.Error == nil {
+ *t = NewDateNano(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *Time) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTime(Parse(string(v)))
+ case string:
+ *t = NewTime(Parse(v))
+ case time.Time:
+ *t = NewTime(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *Time) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for Time struct.
+// 实现 MarshalJSON 接口
+func (t Time) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToTimeString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for Time struct.
+// 实现 UnmarshalJSON 接口
+func (t *Time) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ year, month, day := Now().Date()
+ c := ParseByLayout(fmt.Sprintf("%d-%02d-%02d %s", year, month, day, value), DateTimeLayout)
+ fmt.Println("c", c)
+ if c.Error == nil {
+ *t = NewTime(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *TimeMilli) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimeMilli(Parse(string(v)))
+ case string:
+ *t = NewTimeMilli(Parse(v))
+ case time.Time:
+ *t = NewTimeMilli(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *TimeMilli) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for TimeMilli struct.
+// 实现 MarshalJSON 接口
+func (t TimeMilli) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToTimeMilliString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for TimeMilli struct.
+// 实现 UnmarshalJSON 接口
+func (t *TimeMilli) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ year, month, day := Now().Date()
+ c := ParseByLayout(fmt.Sprintf("%d-%02d-%02d %s", year, month, day, value), DateTimeMilliLayout)
+ if c.Error == nil {
+ *t = NewTimeMilli(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *TimeMicro) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimeMicro(Parse(string(v)))
+ case string:
+ *t = NewTimeMicro(Parse(v))
+ case time.Time:
+ *t = NewTimeMicro(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *TimeMicro) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for TimeMicro struct.
+// 实现 MarshalJSON 接口
+func (t TimeMicro) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToTimeMicroString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for TimeMicro struct.
+// 实现 UnmarshalJSON 接口
+func (t *TimeMicro) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ year, month, day := Now().Date()
+ c := ParseByLayout(fmt.Sprintf("%d-%02d-%02d %s", year, month, day, value), DateTimeMicroLayout)
+ if c.Error == nil {
+ *t = NewTimeMicro(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *TimeNano) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimeNano(Parse(string(v)))
+ case string:
+ *t = NewTimeNano(Parse(v))
+ case time.Time:
+ *t = NewTimeNano(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *TimeNano) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for TimeNano struct.
+// 实现 MarshalJSON 接口
+func (t TimeNano) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`"%s"`, t.ToTimeNanoString())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for TimeNano struct.
+// 实现 UnmarshalJSON 接口
+func (t *TimeNano) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ year, month, day := Now().Date()
+ c := ParseByLayout(fmt.Sprintf("%d-%02d-%02d %s", year, month, day, value), DateTimeNanoLayout)
+ if c.Error == nil {
+ *t = NewTimeNano(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *Timestamp) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimestamp(Parse(string(v)))
+ case string:
+ *t = NewTimestamp(Parse(v))
+ case time.Time:
+ *t = NewTimestamp(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *Timestamp) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for Timestamp struct.
+// 实现 MarshalJSON 接口
+func (t Timestamp) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`%d`, t.Timestamp())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for Timestamp struct.
+// 实现 UnmarshalJSON 接口
+func (t *Timestamp) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ ts, _ := strconv.ParseInt(value, 10, 64)
+ c := CreateFromTimestamp(ts)
+ if c.Error == nil {
+ *t = NewTimestamp(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *TimestampMilli) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimestampMilli(Parse(string(v)))
+ case string:
+ *t = NewTimestampMilli(Parse(v))
+ case time.Time:
+ *t = NewTimestampMilli(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *TimestampMilli) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for TimestampMilli struct.
+// 实现 MarshalJSON 接口
+func (t TimestampMilli) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`%d`, t.TimestampMilli())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for TimestampMilli struct.
+// 实现 UnmarshalJSON 接口
+func (t *TimestampMilli) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ ts, _ := strconv.ParseInt(value, 10, 64)
+ c := CreateFromTimestampMilli(ts)
+ if c.Error == nil {
+ *t = NewTimestampMilli(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *TimestampMicro) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimestampMicro(Parse(string(v)))
+ case string:
+ *t = NewTimestampMicro(Parse(v))
+ case time.Time:
+ *t = NewTimestampMicro(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *TimestampMicro) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface MarshalJSON for TimestampMicro struct.
+// 实现 MarshalJSON 接口
+func (t TimestampMicro) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`%d`, t.TimestampMicro())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for TimestampMicro struct.
+// 实现 UnmarshalJSON 接口
+func (t *TimestampMicro) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ ts, _ := strconv.ParseInt(value, 10, 64)
+ c := CreateFromTimestampMicro(ts)
+ if c.Error == nil {
+ *t = NewTimestampMicro(c)
+ }
+ return c.Error
+}
+
+// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
+func (t *TimestampNano) Scan(src interface{}) error {
+ switch v := src.(type) {
+ case []byte:
+ *t = NewTimestampNano(Parse(string(v)))
+ case string:
+ *t = NewTimestampNano(Parse(v))
+ case time.Time:
+ *t = NewTimestampNano(CreateFromStdTime(v))
+ }
+ if t.Error == nil {
+ return nil
+ }
+ return failedScanError(src)
+}
+
+// Value the interface providing the Value method for package database/sql/driver.
+func (t *TimestampNano) Value() (driver.Value, error) {
+ if t.IsZero() {
+ return nil, nil
+ }
+ return t.StdTime(), nil
+}
+
+// MarshalJSON implements the interface json.Marshal for TimestampNano struct.
+// 实现 MarshalJSON 接口
+func (t TimestampNano) MarshalJSON() ([]byte, error) {
+ return []byte(fmt.Sprintf(`%d`, t.TimestampNano())), nil
+}
+
+// UnmarshalJSON implements the interface json.Unmarshal for TimestampNano struct.
+// 实现 UnmarshalJSON 接口
+func (t *TimestampNano) UnmarshalJSON(b []byte) error {
+ value := fmt.Sprintf("%s", bytes.Trim(b, `"`))
+ if value == "" || value == "null" {
+ return nil
+ }
+ ts, _ := strconv.ParseInt(value, 10, 64)
+ c := CreateFromTimestampNano(ts)
+ if c.Error == nil {
+ *t = NewTimestampNano(c)
+ }
+ return c.Error
+}
+
+// Int64 outputs timestamp with second.
+// 输出秒级时间戳
+func (t Timestamp) Int64() int64 {
+ return t.Timestamp()
+}
+
+// Int64 outputs timestamp with millisecond.
+// 输出豪秒级时间戳
+func (t TimestampMilli) Int64() int64 {
+ return t.TimestampMilli()
+}
+
+// Int64 outputs timestamp with microsecond.
+// 输出微秒级时间戳
+func (t TimestampMicro) Int64() int64 {
+ return t.TimestampMicro()
+}
+
+// Int64 outputs timestamp with nanosecond.
+// 输出纳秒级时间戳
+func (t TimestampNano) Int64() int64 {
+ return t.TimestampNano()
+}
+
+// String implements the interface Stringer for DateTime struct.
+// 实现 Stringer 接口
+func (t DateTime) String() string {
+ return t.ToDateTimeString()
+}
+
+// String implements the interface Stringer for DateTimeMilli struct.
+// 实现 Stringer 接口
+func (t DateTimeMilli) String() string {
+ return t.ToDateTimeMilliString()
+}
+
+// String implements the interface Stringer for DateTimeMicro struct.
+// 实现 Stringer 接口
+func (t DateTimeMicro) String() string {
+ return t.ToDateTimeMicroString()
+}
+
+// String implements the interface Stringer for DateTimeNano struct.
+// 实现 Stringer 接口
+func (t DateTimeNano) String() string {
+ return t.ToDateTimeNanoString()
+}
+
+// String implements the interface Stringer for Date struct.
+// 实现 Stringer 接口
+func (t Date) String() string {
+ return t.ToDateString()
+}
+
+// String implements the interface Stringer for DateMilli struct.
+// 实现 Stringer 接口
+func (t DateMilli) String() string {
+ return t.ToDateMilliString()
+}
+
+// String implements the interface Stringer for DateMicro struct.
+// 实现 Stringer 接口
+func (t DateMicro) String() string {
+ return t.ToDateMicroString()
+}
+
+// String implements the interface Stringer for DateNano struct.
+// 实现 Stringer 接口
+func (t DateNano) String() string {
+ return t.ToDateNanoString()
+}
+
+// String implements the interface Stringer for Time struct.
+// 实现 Stringer 接口
+func (t Time) String() string {
+ return t.ToTimeString()
+}
+
+// String implements the interface Stringer for TimeMilli struct.
+// 实现 Stringer 接口
+func (t TimeMilli) String() string {
+ return t.ToTimeMilliString()
+}
+
+// String implements the interface Stringer for TimeMicro struct.
+// 实现 Stringer 接口
+func (t TimeMicro) String() string {
+ return t.ToTimeMicroString()
+}
+
+// String implements the interface Stringer for TimeNano struct.
+// 实现 Stringer 接口
+func (t TimeNano) String() string {
+ return t.ToTimeNanoString()
+}
+
+// String implements the interface Stringer for Timestamp struct.
+// 实现 Stringer 接口
+func (t Timestamp) String() string {
+ return strconv.FormatInt(t.Timestamp(), 10)
+}
+
+// String implements the interface Stringer for TimestampMilli struct.
+// 实现 Stringer 接口
+func (t TimestampMilli) String() string {
+ return strconv.FormatInt(t.TimestampMilli(), 10)
+}
+
+// String implements the interface Stringer for TimestampMicro struct.
+// 实现 Stringer 接口
+func (t TimestampMicro) String() string {
+ return strconv.FormatInt(t.TimestampMicro(), 10)
+}
+
+// String implements the interface Stringer for TimestampNano struct.
+// 实现 Stringer 接口
+func (t TimestampNano) String() string {
+ return strconv.FormatInt(t.TimestampNano(), 10)
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/default.go b/vendor/github.com/dromara/carbon/v2/default.go
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/default.go
rename to vendor/github.com/dromara/carbon/v2/default.go
diff --git a/vendor/github.com/golang-module/carbon/v2/difference.go b/vendor/github.com/dromara/carbon/v2/difference.go
similarity index 90%
rename from vendor/github.com/golang-module/carbon/v2/difference.go
rename to vendor/github.com/dromara/carbon/v2/difference.go
index 9e3acd1c..414be971 100644
--- a/vendor/github.com/golang-module/carbon/v2/difference.go
+++ b/vendor/github.com/dromara/carbon/v2/difference.go
@@ -6,6 +6,11 @@ import (
"time"
)
+const (
+ minDuration time.Duration = -1 << 63
+ maxDuration time.Duration = 1<<63 - 1
+)
+
// DiffInYears gets the difference in years.
// 相差多少年
func (c Carbon) DiffInYears(carbon ...Carbon) int64 {
@@ -35,20 +40,24 @@ func (c Carbon) DiffAbsInYears(carbon ...Carbon) int64 {
// DiffInMonths gets the difference in months.
// 相差多少月
func (c Carbon) DiffInMonths(carbon ...Carbon) int64 {
- end := c.Now()
- if c.IsSetTestNow() {
+ start, end := c, c.Now()
+ if start.IsSetTestNow() {
end = CreateFromTimestampNano(c.testNow, c.Location())
}
if len(carbon) > 0 {
end = carbon[0]
}
- if c.DiffAbsInDays(end) < 28 {
+ if start.Month() == end.Month() && start.Year() == end.Year() {
return 0
}
- startYear, startMonth, _ := c.Date()
- endYear, endMonth, _ := end.Date()
- diffYear, diffMonth := endYear-startYear, endMonth-startMonth
- return int64(diffYear*MonthsPerYear + diffMonth)
+ dd := start.DiffInDays(end)
+ sign := 1
+ if dd <= 0 {
+ start, end = end, start
+ sign = -1
+ }
+ months := getDiffInMonths(start, end, 0)
+ return months * int64(sign)
}
// DiffAbsInMonths gets the difference in months with absolute value.
@@ -202,14 +211,11 @@ func (c Carbon) DiffInDuration(carbon ...Carbon) time.Duration {
// DiffAbsInDuration gets the difference in duration with absolute value.
// 相差时长(绝对值)
func (c Carbon) DiffAbsInDuration(carbon ...Carbon) time.Duration {
- end := c.Now()
- if c.IsSetTestNow() {
- end = CreateFromTimestampNano(c.testNow, c.Location())
+ d := c.DiffInDuration(carbon...)
+ if d >= 0 {
+ return d
}
- if len(carbon) > 0 {
- end = carbon[0]
- }
- return end.StdTime().Sub(c.StdTime()).Abs()
+ return -d
}
// DiffForHumans gets the difference in a human-readable format, i18n is supported.
@@ -273,3 +279,14 @@ func (c Carbon) diff(end Carbon) (unit string, value int64) {
}
return
}
+
+func getDiffInMonths(start, end Carbon, months int64) int64 {
+ next := start.AddDays(start.DaysInMonth())
+ days := next.DiffInDays(end)
+ seconds := next.DiffInSeconds(end)
+ if days < 0 || (days == 0 && seconds < 0) {
+ return months
+ }
+ months += 1
+ return getDiffInMonths(next, end, months)
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/errors.go b/vendor/github.com/dromara/carbon/v2/errors.go
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/errors.go
rename to vendor/github.com/dromara/carbon/v2/errors.go
diff --git a/vendor/github.com/golang-module/carbon/v2/extremum.go b/vendor/github.com/dromara/carbon/v2/extremum.go
similarity index 73%
rename from vendor/github.com/golang-module/carbon/v2/extremum.go
rename to vendor/github.com/dromara/carbon/v2/extremum.go
index 8eb1a6c1..22a39a78 100644
--- a/vendor/github.com/golang-module/carbon/v2/extremum.go
+++ b/vendor/github.com/dromara/carbon/v2/extremum.go
@@ -1,12 +1,24 @@
package carbon
+// MaxValue returns a Carbon instance for the greatest supported date.
+// 返回 Carbon 的最大值
+func MaxValue() Carbon {
+ return NewCarbon().create(9999, 12, 31, 23, 59, 59, 999999999, UTC)
+}
+
+// MinValue returns a Carbon instance for the lowest supported date.
+// 返回 Carbon 的最小值
+func MinValue() Carbon {
+ return NewCarbon().create(-9998, 1, 1, 0, 0, 0, 0, UTC)
+}
+
// Closest returns the closest Carbon instance from the given Carbon instance.
// 返回离给定 carbon 实例最近的 Carbon 实例
func (c Carbon) Closest(c1 Carbon, c2 Carbon) Carbon {
- if c1.IsZero() || c1.IsInvalid() {
+ if c1.Error != nil {
return c2
}
- if c2.IsZero() || c2.IsInvalid() {
+ if c2.Error != nil {
return c1
}
if c.DiffAbsInSeconds(c1) < c.DiffAbsInSeconds(c2) {
diff --git a/vendor/github.com/golang-module/carbon/v2/getter.go b/vendor/github.com/dromara/carbon/v2/getter.go
similarity index 89%
rename from vendor/github.com/golang-module/carbon/v2/getter.go
rename to vendor/github.com/dromara/carbon/v2/getter.go
index 9e8bd4a8..112848c8 100644
--- a/vendor/github.com/golang-module/carbon/v2/getter.go
+++ b/vendor/github.com/dromara/carbon/v2/getter.go
@@ -4,16 +4,19 @@ import (
"time"
)
-// StdTime converts Carbon to standard time.Time.
-// 将 Carbon 转换成标准 time.Time
+// StdTime gets standard time.Time.
+// 获取标准 time.Time
func (c Carbon) StdTime() time.Time {
+ if c.time.IsZero() {
+ return c.time
+ }
return c.time.In(c.loc)
}
// DaysInYear gets total days in year like 365.
// 获取本年的总天数
func (c Carbon) DaysInYear() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
if c.IsLeapYear() {
@@ -25,16 +28,16 @@ func (c Carbon) DaysInYear() int {
// DaysInMonth gets total days in month like 30.
// 获取本月的总天数
func (c Carbon) DaysInMonth() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
- return c.EndOfMonth().time.In(c.loc).Day()
+ return c.EndOfMonth().StdTime().Day()
}
// MonthOfYear gets month of year like 12.
// 获取本年的第几月
func (c Carbon) MonthOfYear() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return int(c.StdTime().Month())
@@ -43,7 +46,7 @@ func (c Carbon) MonthOfYear() int {
// DayOfYear gets day of year like 365.
// 获取本年的第几天
func (c Carbon) DayOfYear() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().YearDay()
@@ -52,7 +55,7 @@ func (c Carbon) DayOfYear() int {
// DayOfMonth gets day of month like 30.
// 获取本月的第几天
func (c Carbon) DayOfMonth() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Day()
@@ -61,7 +64,7 @@ func (c Carbon) DayOfMonth() int {
// DayOfWeek gets day of week like 6.
// 获取本周的第几天
func (c Carbon) DayOfWeek() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
day := int(c.StdTime().Weekday())
@@ -74,7 +77,7 @@ func (c Carbon) DayOfWeek() int {
// WeekOfYear gets week of year like 1, see https://en.wikipedia.org/wiki/ISO_8601#Week_dates.
// 获取本年的第几周
func (c Carbon) WeekOfYear() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
_, week := c.StdTime().ISOWeek()
@@ -84,7 +87,7 @@ func (c Carbon) WeekOfYear() int {
// WeekOfMonth gets week of month like 1.
// 获取本月的第几周
func (c Carbon) WeekOfMonth() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
days := c.Day() + c.StartOfMonth().DayOfWeek() - 1
@@ -97,7 +100,7 @@ func (c Carbon) WeekOfMonth() int {
// DateTime gets current year, month, day, hour, minute, and second like 2020, 8, 5, 13, 14, 15.
// 获取当前年、月、日、时、分、秒
func (c Carbon) DateTime() (year, month, day, hour, minute, second int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day = c.Date()
@@ -108,7 +111,7 @@ func (c Carbon) DateTime() (year, month, day, hour, minute, second int) {
// DateTimeMilli gets current year, month, day, hour, minute, second and millisecond like 2020, 8, 5, 13, 14, 15, 999.
// 获取当前年、月、日、时、分、秒、毫秒
func (c Carbon) DateTimeMilli() (year, month, day, hour, minute, second, millisecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day, hour, minute, second = c.DateTime()
@@ -118,7 +121,7 @@ func (c Carbon) DateTimeMilli() (year, month, day, hour, minute, second, millise
// DateTimeMicro gets current year, month, day, hour, minute, second and microsecond like 2020, 8, 5, 13, 14, 15, 999999.
// 获取当前年、月、日、时、分、秒、微秒
func (c Carbon) DateTimeMicro() (year, month, day, hour, minute, second, microsecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day, hour, minute, second = c.DateTime()
@@ -128,7 +131,7 @@ func (c Carbon) DateTimeMicro() (year, month, day, hour, minute, second, microse
// DateTimeNano gets current year, month, day, hour, minute, second and nanosecond like 2020, 8, 5, 13, 14, 15, 999999999.
// 获取当前年、月、日、时、分、秒、纳秒
func (c Carbon) DateTimeNano() (year, month, day, hour, minute, second, nanosecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day, hour, minute, second = c.DateTime()
@@ -138,7 +141,7 @@ func (c Carbon) DateTimeNano() (year, month, day, hour, minute, second, nanoseco
// Date gets current year, month, and day like 2020, 8, 5.
// 获取当前年、月、日
func (c Carbon) Date() (year, month, day int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
var tm time.Month
@@ -149,7 +152,7 @@ func (c Carbon) Date() (year, month, day int) {
// DateMilli gets current year, month, day and millisecond like 2020, 8, 5, 999.
// 获取当前年、月、日、毫秒
func (c Carbon) DateMilli() (year, month, day, millisecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day = c.Date()
@@ -159,7 +162,7 @@ func (c Carbon) DateMilli() (year, month, day, millisecond int) {
// DateMicro gets current year, month, day and microsecond like 2020, 8, 5, 999999.
// 获取当前年、月、日、微秒
func (c Carbon) DateMicro() (year, month, day, microsecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day = c.Date()
@@ -169,7 +172,7 @@ func (c Carbon) DateMicro() (year, month, day, microsecond int) {
// DateNano gets current year, month, day and nanosecond like 2020, 8, 5, 999999999.
// 获取当前年、月、日、纳秒
func (c Carbon) DateNano() (year, month, day, nanosecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
year, month, day = c.Date()
@@ -179,7 +182,7 @@ func (c Carbon) DateNano() (year, month, day, nanosecond int) {
// Time gets current hour, minute, and second like 13, 14, 15.
// 获取当前时、分、秒
func (c Carbon) Time() (hour, minute, second int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
return c.StdTime().Clock()
@@ -188,7 +191,7 @@ func (c Carbon) Time() (hour, minute, second int) {
// TimeMilli gets current hour, minute, second and millisecond like 13, 14, 15, 999.
// 获取当前时、分、秒、毫秒
func (c Carbon) TimeMilli() (hour, minute, second, millisecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
hour, minute, second = c.Time()
@@ -198,7 +201,7 @@ func (c Carbon) TimeMilli() (hour, minute, second, millisecond int) {
// TimeMicro gets current hour, minute, second and microsecond like 13, 14, 15, 999999.
// 获取当前时、分、秒、微秒
func (c Carbon) TimeMicro() (hour, minute, second, microsecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
hour, minute, second = c.Time()
@@ -208,7 +211,7 @@ func (c Carbon) TimeMicro() (hour, minute, second, microsecond int) {
// TimeNano gets current hour, minute, second and nanosecond like 13, 14, 15, 999999999.
// 获取当前时、分、秒、纳秒
func (c Carbon) TimeNano() (hour, minute, second, nanosecond int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
hour, minute, second = c.Time()
@@ -218,7 +221,7 @@ func (c Carbon) TimeNano() (hour, minute, second, nanosecond int) {
// Century gets current century like 21.
// 获取当前世纪
func (c Carbon) Century() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.Year()/YearsPerCentury + 1
@@ -227,7 +230,7 @@ func (c Carbon) Century() int {
// Decade gets current decade like 20.
// 获取当前年代
func (c Carbon) Decade() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.Year() % YearsPerCentury / YearsPerDecade * YearsPerDecade
@@ -236,7 +239,7 @@ func (c Carbon) Decade() int {
// Year gets current year like 2020.
// 获取当前年
func (c Carbon) Year() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Year()
@@ -245,7 +248,7 @@ func (c Carbon) Year() int {
// Quarter gets current quarter like 3.
// 获取当前季度
func (c Carbon) Quarter() (quarter int) {
- if c.IsInvalid() {
+ if c.Error != nil {
return
}
month := c.Month()
@@ -271,7 +274,7 @@ func (c Carbon) Month() int {
// Week gets current week like 6, start from 0.
// 获取当前周(从0开始)
func (c Carbon) Week() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return -1
}
return (c.DayOfWeek() + DaysPerWeek - int(c.weekStartsAt)) % DaysPerWeek
@@ -286,7 +289,7 @@ func (c Carbon) Day() int {
// Hour gets current hour like 13.
// 获取当前小时
func (c Carbon) Hour() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Hour()
@@ -295,7 +298,7 @@ func (c Carbon) Hour() int {
// Minute gets current minute like 14.
// 获取当前分钟数
func (c Carbon) Minute() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Minute()
@@ -304,7 +307,7 @@ func (c Carbon) Minute() int {
// Second gets current second like 15.
// 获取当前秒数
func (c Carbon) Second() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Second()
@@ -313,7 +316,7 @@ func (c Carbon) Second() int {
// Millisecond gets current millisecond like 999.
// 获取当前毫秒数
func (c Carbon) Millisecond() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Nanosecond() / 1e6
@@ -322,7 +325,7 @@ func (c Carbon) Millisecond() int {
// Microsecond gets current microsecond like 999999.
// 获取当前微秒数
func (c Carbon) Microsecond() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Nanosecond() / 1e3
@@ -331,7 +334,7 @@ func (c Carbon) Microsecond() int {
// Nanosecond gets current nanosecond like 999999999.
// 获取当前纳秒数
func (c Carbon) Nanosecond() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Nanosecond()
@@ -340,7 +343,7 @@ func (c Carbon) Nanosecond() int {
// Timestamp gets timestamp with second like 1596604455.
// 输出秒级时间戳
func (c Carbon) Timestamp() int64 {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().Unix()
@@ -349,7 +352,7 @@ func (c Carbon) Timestamp() int64 {
// TimestampMilli gets timestamp with millisecond like 1596604455000.
// 获取毫秒级时间戳
func (c Carbon) TimestampMilli() int64 {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
t := c.StdTime()
@@ -359,7 +362,7 @@ func (c Carbon) TimestampMilli() int64 {
// TimestampMicro gets timestamp with microsecond like 1596604455000000.
// 获取微秒级时间戳
func (c Carbon) TimestampMicro() int64 {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
t := c.StdTime()
@@ -369,7 +372,7 @@ func (c Carbon) TimestampMicro() int64 {
// TimestampNano gets timestamp with nanosecond like 1596604455000000000.
// 获取纳秒级时间戳
func (c Carbon) TimestampNano() int64 {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
return c.StdTime().UnixNano()
@@ -378,12 +381,18 @@ func (c Carbon) TimestampNano() int64 {
// Location gets location name like "PRC".
// 获取位置
func (c Carbon) Location() string {
+ if c.Error != nil {
+ return ""
+ }
return c.loc.String()
}
// Timezone gets timezone name like "CST".
// 获取时区
func (c Carbon) Timezone() string {
+ if c.Error != nil {
+ return ""
+ }
name, _ := c.StdTime().Zone()
return name
}
@@ -391,6 +400,9 @@ func (c Carbon) Timezone() string {
// Offset gets offset seconds from the UTC timezone like 28800.
// 获取距离UTC时区的偏移量,单位秒
func (c Carbon) Offset() int {
+ if c.Error != nil {
+ return 0
+ }
_, offset := c.StdTime().Zone()
return offset
}
@@ -398,13 +410,16 @@ func (c Carbon) Offset() int {
// Locale gets locale name like "zh-CN".
// 获取语言区域
func (c Carbon) Locale() string {
+ if c.Error != nil {
+ return ""
+ }
return c.lang.locale
}
// Age gets age like 18.
// 获取年龄
func (c Carbon) Age() int {
- if c.IsInvalid() {
+ if c.Error != nil {
return 0
}
now := c.Now()
diff --git a/vendor/github.com/golang-module/carbon/v2/helper.go b/vendor/github.com/dromara/carbon/v2/helper.go
similarity index 99%
rename from vendor/github.com/golang-module/carbon/v2/helper.go
rename to vendor/github.com/dromara/carbon/v2/helper.go
index d98c48b8..92d8e8b8 100644
--- a/vendor/github.com/golang-module/carbon/v2/helper.go
+++ b/vendor/github.com/dromara/carbon/v2/helper.go
@@ -64,6 +64,7 @@ var layouts = []string{
"2006-1", "2006-1-2", "2006-1-2 15", "2006-1-2 15:4", "2006-1-2 15:4:5", "2006-1-2 15:4:5.999999999",
"2006.1", "2006.1.2", "2006.1.2 15", "2006.1.2 15:4", "2006.1.2 15:4:5", "2006.1.2 15:4:5.999999999",
"2006/1", "2006/1/2", "2006/1/2 15", "2006/1/2 15:4", "2006/1/2 15:4:5", "2006/1/2 15:4:5.999999999",
+ "2006-01-02 15:04:05 -0700 MST",
"2006-01-02 15:04:05PM MST", "2006-01-02 15:04:05.999999999PM MST", "2006-1-2 15:4:5PM MST", "2006-1-2 15:4:5.999999999PM MST",
"2006-01-02 15:04:05 PM MST", "2006-01-02 15:04:05.999999999 PM MST", "2006-1-2 15:4:5 PM MST", "2006-1-2 15:4:5.999999999 PM MST",
"1/2/2006", "1/2/2006 15", "1/2/2006 15:4", "1/2/2006 15:4:5", "1/2/2006 15:4:5.999999999",
diff --git a/vendor/github.com/dromara/carbon/v2/lang/ar.json b/vendor/github.com/dromara/carbon/v2/lang/ar.json
new file mode 100644
index 00000000..26d78f5f
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/lang/ar.json
@@ -0,0 +1,21 @@
+{
+ "name": "Arabic",
+ "months": "يناير|فبراير|مارس|أبريل|مايو|يونيو|يوليو|أغسطس|سبتمبر|أكتوبر|نوفمبر|ديسمبر",
+ "short_months": "يناير|فبراير|مارس|أبريل|مايو|يونيو|يوليو|أغسطس|سبتمبر|أكتوبر|نوفمبر|ديسمبر",
+ "weeks": "الأحد|الإثنين|الثلاثاء|الأربعاء|الخميس|الجمعة|السبت",
+ "short_weeks": "أحد|إثنين|ثلاثاء|أربعاء|خميس|جمعة|سبت",
+ "seasons": "الربيع|الصيف|الخريف|الشتاء",
+ "constellations": "الحمل|الثور|الجوزاء|السرطان|الأسد|العذراء|الميزان|العقرب|القوس|الجدي|الدلو|الحوت",
+ "year": "1 سنة|%d سنوات",
+ "month": "1 شهر|%d أشهر",
+ "week": "1 أسبوع|%d أسابيع",
+ "day": "1 يوم|%d أيام",
+ "hour": "1 ساعة|%d ساعات",
+ "minute": "1 دقيقة|%d دقائق",
+ "second": "1 ثانية|%d ثواني",
+ "now": "الآن",
+ "ago": "%s مضت",
+ "from_now": "من %s",
+ "before": "%s قبل",
+ "after": "%s بعد"
+}
diff --git a/vendor/github.com/dromara/carbon/v2/lang/bg.json b/vendor/github.com/dromara/carbon/v2/lang/bg.json
new file mode 100644
index 00000000..8bd3fa7f
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/lang/bg.json
@@ -0,0 +1,21 @@
+{
+ "name": "Български",
+ "months": "Януари|Февруари|Март|Април|Май|Юни|Юли|Август|Септември|Октомври|Ноември|Декември",
+ "short_months": "Ян|Фев|Март|Апр|Май|Юни|Юли|Авг|Сеп|Окт|Ноем|Дек",
+ "weeks": "Неделя|Понеделник|Вторник|Сряда|Четвъртък|Петък|Събота",
+ "short_weeks": "Нд|Пн|Вт|Ср|Чт|Пт|Сб",
+ "seasons": "Пролет|Лято|Есен|Зима",
+ "constellations": "Овен|Телец|Близнаци|Рак|Лъв|Дева|Везни|Скорпион|Стрелец|Козирог|Водолей|Риби",
+ "year": "1 година|%d години",
+ "month": "1 месец|%d месеца",
+ "week": "1 седмица|%d седмици",
+ "day": "1 ден|%d дни",
+ "hour": "1 час|%d часа",
+ "minute": "1 минута|%d минути",
+ "second": "1 секунда|%d секунди",
+ "now": "в момента",
+ "ago": "%s преди",
+ "from_now": "%s от сега",
+ "before": "%s преди",
+ "after": "%s след"
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/de.json b/vendor/github.com/dromara/carbon/v2/lang/de.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/de.json
rename to vendor/github.com/dromara/carbon/v2/lang/de.json
diff --git a/vendor/github.com/dromara/carbon/v2/lang/dk.json b/vendor/github.com/dromara/carbon/v2/lang/dk.json
new file mode 100644
index 00000000..a4230316
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/lang/dk.json
@@ -0,0 +1,21 @@
+{
+ "name": "Dansk",
+ "months": "januar|februar|marts|april|maj|juni|juli|august|september|oktober|november|december",
+ "short_months": "jan|feb|mar|apr|maj|jun|jul|aug|sep|okt|nov|dec",
+ "weeks": "søndag|mandag|tirsdag|onsdag|torsdag|fredag|lørdag",
+ "short_weeks": "søn|man|tir|ons|tor|fre|lør",
+ "seasons": "forår|sommer|efterår|vinter",
+ "constellations": "vædder|tyr|tvilling|krebs|løve|jomfru|vægt|skorpion|skytte|stenbuk|vandmand|fisk",
+ "year": "1 år|%d år",
+ "month": "1 måned|%d måneder",
+ "week": "1 uge|%d uger",
+ "day": "1 dag|%d dage",
+ "hour": "1 time|%d timer",
+ "minute": "1 minut|%d minutter",
+ "second": "1 sekund|%d sekunder",
+ "now": "lige nu",
+ "ago": "%s siden",
+ "from_now": "om %s",
+ "before": "%s før",
+ "after": "%s efter"
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/en.json b/vendor/github.com/dromara/carbon/v2/lang/en.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/en.json
rename to vendor/github.com/dromara/carbon/v2/lang/en.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/es.json b/vendor/github.com/dromara/carbon/v2/lang/es.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/es.json
rename to vendor/github.com/dromara/carbon/v2/lang/es.json
diff --git a/vendor/github.com/dromara/carbon/v2/lang/fa.json b/vendor/github.com/dromara/carbon/v2/lang/fa.json
new file mode 100644
index 00000000..7d10d9d2
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/lang/fa.json
@@ -0,0 +1,21 @@
+{
+ "name": "Farsi",
+ "months": "ژانویه|فوریه|مارس|آوریل|مه|ژوئن|ژوئیه|اوت|سپتامبر|اکتبر|نوامبر|دسامبر",
+ "short_months": "ژانویه|فوریه|مارس|آوریل|مه|ژوئن|ژوئیه|اوت|سپتامبر|اکتبر|نوامبر|دسامبر",
+ "weeks": "یکشنبه|دوشنبه|سهشنبه|چهارشنبه|پنجشنبه|جمعه|شنبه",
+ "short_weeks": "یکشنبه|دوشنبه|سهشنبه|چهارشنبه|پنجشنبه|جمعه|شنبه",
+ "seasons": "بهار|تابستان|پاییز|زمستان",
+ "constellations": "قوچ|گاو نر|دو پیکر|خرچنگ|شیر|خوشه|ترازو|عقرب|کماندار|بز|آبریز|ماهی",
+ "year": "1 سال|%d سال",
+ "month": "1 ماه|%d ماه",
+ "week": "1 هفته|%d هفته",
+ "day": "1 روز|%d روز",
+ "hour": "1 ساعت|%d ساعت",
+ "minute": "1 دقیقه|%d دقیقه",
+ "second": "1 ثانیه|%d ثانیه",
+ "now": "همین الان",
+ "ago": "%s پیش",
+ "from_now": "در %s",
+ "before": "%s قبل",
+ "after": "%s بعد"
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/fr.json b/vendor/github.com/dromara/carbon/v2/lang/fr.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/fr.json
rename to vendor/github.com/dromara/carbon/v2/lang/fr.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/hi.json b/vendor/github.com/dromara/carbon/v2/lang/hi.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/hi.json
rename to vendor/github.com/dromara/carbon/v2/lang/hi.json
diff --git a/vendor/github.com/dromara/carbon/v2/lang/hu.json b/vendor/github.com/dromara/carbon/v2/lang/hu.json
new file mode 100644
index 00000000..edcf23f1
--- /dev/null
+++ b/vendor/github.com/dromara/carbon/v2/lang/hu.json
@@ -0,0 +1,21 @@
+{
+ "name": "Hungarian",
+ "months": "január|február|március|április|május|június|július|augusztus|szeptember|október|november|december",
+ "short_months": "jan.|febr.|márc.|ápr.|máj.|jún.|júl.|aug.|szept.|okt.|nov.|dec.",
+ "weeks": "Vasárnap|Hétfő|Kedd|Szerda|Csütörtök|Péntek|Szombat",
+ "short_weeks": "Vas|Hét|Ke|Sze|Csü|Pé|Szo",
+ "seasons": "Tavasz|Nyár|Ősz|Tél",
+ "constellations": "Kos|Bika|Ikrek|Rák|Oroszlán|Szűz|Mérleg|Skorpió|Nyilas|Bak|Vízöntő|Halak",
+ "year": "1 év|%d év",
+ "month": "1 hónap|%d hónap",
+ "week": "1 hét|%d hét",
+ "day": "1 nap|%d nap",
+ "hour": "1 óra|%d óra",
+ "minute": "1 perc|%d perc",
+ "second": "1 másodperc|%d másodperc",
+ "now": "most",
+ "ago": "%s",
+ "from_now": "%s múlva",
+ "before": "%s korábban",
+ "after": "%s később"
+}
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/id.json b/vendor/github.com/dromara/carbon/v2/lang/id.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/id.json
rename to vendor/github.com/dromara/carbon/v2/lang/id.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/it.json b/vendor/github.com/dromara/carbon/v2/lang/it.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/it.json
rename to vendor/github.com/dromara/carbon/v2/lang/it.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/jp.json b/vendor/github.com/dromara/carbon/v2/lang/jp.json
similarity index 67%
rename from vendor/github.com/golang-module/carbon/v2/lang/jp.json
rename to vendor/github.com/dromara/carbon/v2/lang/jp.json
index 60869383..e5808401 100644
--- a/vendor/github.com/golang-module/carbon/v2/lang/jp.json
+++ b/vendor/github.com/dromara/carbon/v2/lang/jp.json
@@ -1,7 +1,7 @@
{
"name": "Japanese",
- "months": "いちがつ|にがつ|さんがつ|しがつ|ごがつ|ろくがつ|しちがつ|はちがつ|くがつ|じゅうがつ|じゅういちがつ|じゅうにがつ",
- "short_months": "1がつ|2がつ|3がつ|4がつ|5がつ|6がつ|7がつ|8がつ|9がつ|10がつ|11がつ|12がつ",
+ "months": "1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月",
+ "short_months": "1月|2月|3月|4月|5月|6月|7月|8月|9月|10月|11月|12月",
"weeks": "日曜日|月曜日|火曜日|水曜日|木曜日|金曜日|土曜日",
"short_weeks": "日|月|火|水|木|金|土",
"seasons": "春|夏|秋|冬",
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/kr.json b/vendor/github.com/dromara/carbon/v2/lang/kr.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/kr.json
rename to vendor/github.com/dromara/carbon/v2/lang/kr.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/ms-MY.json b/vendor/github.com/dromara/carbon/v2/lang/ms-MY.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/ms-MY.json
rename to vendor/github.com/dromara/carbon/v2/lang/ms-MY.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/nl.json b/vendor/github.com/dromara/carbon/v2/lang/nl.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/nl.json
rename to vendor/github.com/dromara/carbon/v2/lang/nl.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/pl.json b/vendor/github.com/dromara/carbon/v2/lang/pl.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/pl.json
rename to vendor/github.com/dromara/carbon/v2/lang/pl.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/pt.json b/vendor/github.com/dromara/carbon/v2/lang/pt.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/pt.json
rename to vendor/github.com/dromara/carbon/v2/lang/pt.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/ro.json b/vendor/github.com/dromara/carbon/v2/lang/ro.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/ro.json
rename to vendor/github.com/dromara/carbon/v2/lang/ro.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/ru.json b/vendor/github.com/dromara/carbon/v2/lang/ru.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/ru.json
rename to vendor/github.com/dromara/carbon/v2/lang/ru.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/se.json b/vendor/github.com/dromara/carbon/v2/lang/se.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/se.json
rename to vendor/github.com/dromara/carbon/v2/lang/se.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/th.json b/vendor/github.com/dromara/carbon/v2/lang/th.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/th.json
rename to vendor/github.com/dromara/carbon/v2/lang/th.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/tr.json b/vendor/github.com/dromara/carbon/v2/lang/tr.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/tr.json
rename to vendor/github.com/dromara/carbon/v2/lang/tr.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/uk.json b/vendor/github.com/dromara/carbon/v2/lang/uk.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/uk.json
rename to vendor/github.com/dromara/carbon/v2/lang/uk.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/vi.json b/vendor/github.com/dromara/carbon/v2/lang/vi.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/vi.json
rename to vendor/github.com/dromara/carbon/v2/lang/vi.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/zh-CN.json b/vendor/github.com/dromara/carbon/v2/lang/zh-CN.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/zh-CN.json
rename to vendor/github.com/dromara/carbon/v2/lang/zh-CN.json
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/zh-TW.json b/vendor/github.com/dromara/carbon/v2/lang/zh-TW.json
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/lang/zh-TW.json
rename to vendor/github.com/dromara/carbon/v2/lang/zh-TW.json
diff --git a/vendor/github.com/golang-module/carbon/v2/language.go b/vendor/github.com/dromara/carbon/v2/language.go
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/language.go
rename to vendor/github.com/dromara/carbon/v2/language.go
diff --git a/vendor/github.com/golang-module/carbon/v2/outputer.go b/vendor/github.com/dromara/carbon/v2/outputer.go
similarity index 97%
rename from vendor/github.com/golang-module/carbon/v2/outputer.go
rename to vendor/github.com/dromara/carbon/v2/outputer.go
index 6cc4b29b..ebad07ad 100644
--- a/vendor/github.com/golang-module/carbon/v2/outputer.go
+++ b/vendor/github.com/dromara/carbon/v2/outputer.go
@@ -5,20 +5,12 @@ import (
"fmt"
"strconv"
"strings"
- "time"
)
// String implements the interface Stringer for Carbon struct.
// 实现 Stringer 接口
func (c Carbon) String() string {
- key, value, tz := c.parseTag()
- if key == "layout" {
- return c.Layout(value, tz)
- }
- if key == "format" {
- return c.Format(value, tz)
- }
- return c.ToDateTimeString(c.Location())
+ return c.Layout(c.layout, c.Location())
}
// GoString implements fmt.GoStringer and formats c to be printed in Go source code.
@@ -33,29 +25,29 @@ func (c Carbon) GoString() string {
// ToString outputs a string in "2006-01-02 15:04:05.999999999 -0700 MST" layout.
// 输出 "2006-01-02 15:04:05.999999999 -0700 MST" 格式字符串
func (c Carbon) ToString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().String()
}
// ToMonthString outputs a string in month layout like "January", i18n is supported.
// 输出完整月份字符串,支持i18n
func (c Carbon) ToMonthString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
if len(c.lang.resources) == 0 {
c.lang.SetLocale(defaultLocale)
}
- c.lang.rw.Lock()
- defer c.lang.rw.Unlock()
+ c.lang.rw.RLock()
+ defer c.lang.rw.RUnlock()
if resources, ok := c.lang.resources["months"]; ok {
slice := strings.Split(resources, "|")
if len(slice) == MonthsPerYear {
@@ -68,17 +60,17 @@ func (c Carbon) ToMonthString(timezone ...string) string {
// ToShortMonthString outputs a string in short month layout like "Jan", i18n is supported.
// 输出缩写月份字符串,支持i18n
func (c Carbon) ToShortMonthString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
if len(c.lang.resources) == 0 {
c.lang.SetLocale(defaultLocale)
}
- c.lang.rw.Lock()
- defer c.lang.rw.Unlock()
+ c.lang.rw.RLock()
+ defer c.lang.rw.RUnlock()
if resources, ok := c.lang.resources["short_months"]; ok {
slice := strings.Split(resources, "|")
if len(slice) == MonthsPerYear {
@@ -91,17 +83,17 @@ func (c Carbon) ToShortMonthString(timezone ...string) string {
// ToWeekString outputs a string in week layout like "Sunday", i18n is supported.
// 输出完整星期字符串,支持i18n
func (c Carbon) ToWeekString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
if len(c.lang.resources) == 0 {
c.lang.SetLocale(defaultLocale)
}
- c.lang.rw.Lock()
- defer c.lang.rw.Unlock()
+ c.lang.rw.RLock()
+ defer c.lang.rw.RUnlock()
if resources, ok := c.lang.resources["weeks"]; ok {
slice := strings.Split(resources, "|")
if len(slice) == DaysPerWeek {
@@ -114,17 +106,17 @@ func (c Carbon) ToWeekString(timezone ...string) string {
// ToShortWeekString outputs a string in short week layout like "Sun", i18n is supported.
// 输出缩写星期字符串,支持i18n
func (c Carbon) ToShortWeekString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
if len(c.lang.resources) == 0 {
c.lang.SetLocale(defaultLocale)
}
- c.lang.rw.Lock()
- defer c.lang.rw.Unlock()
+ c.lang.rw.RLock()
+ defer c.lang.rw.RUnlock()
if resources, ok := c.lang.resources["short_weeks"]; ok {
slice := strings.Split(resources, "|")
if len(slice) == DaysPerWeek {
@@ -137,684 +129,684 @@ func (c Carbon) ToShortWeekString(timezone ...string) string {
// ToDayDateTimeString outputs a string in "Mon, Jan 2, 2006 3:04 PM" layout.
// 输出 "Mon, Jan 2, 2006 3:04 PM" 格式字符串
func (c Carbon) ToDayDateTimeString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DayDateTimeLayout)
}
// ToDateTimeString outputs a string in "2006-01-02 15:04:05" layout.
// 输出 "2006-01-02 15:04:05" 格式字符串
func (c Carbon) ToDateTimeString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateTimeLayout)
}
// ToDateTimeMilliString outputs a string in "2006-01-02 15:04:05.999" layout.
// 输出 "2006-01-02 15:04:05.999" 格式字符串
func (c Carbon) ToDateTimeMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateTimeMilliLayout)
}
// ToDateTimeMicroString outputs a string in "2006-01-02 15:04:05.999999" layout.
// 输出 "2006-01-02 15:04:05.999999" 格式字符串
func (c Carbon) ToDateTimeMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateTimeMicroLayout)
}
// ToDateTimeNanoString outputs a string in "2006-01-02 15:04:05.999999999" layout.
// 输出 "2006-01-02 15:04:05.999999999" 格式字符串
func (c Carbon) ToDateTimeNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateTimeNanoLayout)
}
// ToShortDateTimeString outputs a string in "20060102150405" layout.
// 输出 "20060102150405" 格式字符串
func (c Carbon) ToShortDateTimeString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateTimeLayout)
}
// ToShortDateTimeMilliString outputs a string in "20060102150405.999" layout.
// 输出 "20060102150405.999" 格式字符串
func (c Carbon) ToShortDateTimeMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateTimeMilliLayout)
}
// ToShortDateTimeMicroString outputs a string in "20060102150405.999999" layout.
// 输出 "20060102150405.999999" 格式字符串
func (c Carbon) ToShortDateTimeMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateTimeMicroLayout)
}
// ToShortDateTimeNanoString outputs a string in "20060102150405.999999999" layout.
// 输出 "20060102150405.999999999" 格式字符串
func (c Carbon) ToShortDateTimeNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateTimeNanoLayout)
}
// ToDateString outputs a string in "2006-01-02" layout.
// 输出 "2006-01-02" 格式字符串
func (c Carbon) ToDateString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateLayout)
}
// ToDateMilliString outputs a string in "2006-01-02.999" layout.
// 输出 "2006-01-02.999" 格式字符串
func (c Carbon) ToDateMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateMilliLayout)
}
// ToDateMicroString outputs a string in "2006-01-02.999999" layout.
// 输出 "2006-01-02.999999" 格式字符串
func (c Carbon) ToDateMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateMicroLayout)
}
// ToDateNanoString outputs a string in "2006-01-02.999999999" layout.
// 输出 "2006-01-02.999999999" 格式字符串
func (c Carbon) ToDateNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(DateNanoLayout)
}
// ToShortDateString outputs a string in "20060102" layout.
// 输出 "20060102" 格式字符串
func (c Carbon) ToShortDateString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateLayout)
}
// ToShortDateMilliString outputs a string in "20060102.999" layout.
// 输出 "20060102.999" 格式字符串
func (c Carbon) ToShortDateMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateMilliLayout)
}
// ToShortDateMicroString outputs a string in "20060102.999999" layout.
// 输出 "20060102.999999" 格式字符串
func (c Carbon) ToShortDateMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateMicroLayout)
}
// ToShortDateNanoString outputs a string in "20060102.999999999" layout.
// 输出 "20060102.999999999" 格式字符串
func (c Carbon) ToShortDateNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortDateNanoLayout)
}
// ToTimeString outputs a string in "15:04:05" layout.
// 输出 "15:04:05" 格式字符串
func (c Carbon) ToTimeString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(TimeLayout)
}
// ToTimeMilliString outputs a string in "15:04:05.999" layout.
// 输出 "15:04:05.999" 格式字符串
func (c Carbon) ToTimeMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(TimeMilliLayout)
}
// ToTimeMicroString outputs a string in "15:04:05.999999" layout.
// 输出 "15:04:05.999999" 格式字符串
func (c Carbon) ToTimeMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(TimeMicroLayout)
}
// ToTimeNanoString outputs a string in "15:04:05.999999999" layout.
// 输出 "15:04:05.999999999" 格式字符串
func (c Carbon) ToTimeNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(TimeNanoLayout)
}
// ToShortTimeString outputs a string in "150405" layout.
// 输出 "150405" 格式字符串
func (c Carbon) ToShortTimeString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortTimeLayout)
}
// ToShortTimeMilliString outputs a string in "150405.999" layout.
// 输出 "150405.999" 格式字符串
func (c Carbon) ToShortTimeMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortTimeMilliLayout)
}
// ToShortTimeMicroString outputs a string in "150405.999999" layout.
// 输出 "150405.999999" 格式字符串
func (c Carbon) ToShortTimeMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortTimeMicroLayout)
}
// ToShortTimeNanoString outputs a string in "150405.999999999" layout.
// 输出 "150405.999999999" 格式字符串
func (c Carbon) ToShortTimeNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ShortTimeNanoLayout)
}
// ToAtomString outputs a string in "2006-01-02T15:04:05Z07:00" layout.
// 输出 "2006-01-02T15:04:05Z07:00" 格式字符串
func (c Carbon) ToAtomString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(AtomLayout)
}
// ToAnsicString outputs a string in "Mon Jan _2 15:04:05 2006" layout.
// 输出 "Mon Jan _2 15:04:05 2006" 格式字符串
func (c Carbon) ToAnsicString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ANSICLayout)
}
// ToCookieString outputs a string in "Monday, 02-Jan-2006 15:04:05 MST" layout.
// 输出 "Monday, 02-Jan-2006 15:04:05 MST" 格式字符串
func (c Carbon) ToCookieString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(CookieLayout)
}
// ToRssString outputs a string in "Mon, 02 Jan 2006 15:04:05 -0700" format.
// 输出 "Mon, 02 Jan 2006 15:04:05 -0700" 格式字符串
func (c Carbon) ToRssString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RssLayout)
}
// ToW3cString outputs a string in "2006-01-02T15:04:05Z07:00" layout.
// 输出 "2006-01-02T15:04:05Z07:00" 格式字符串
func (c Carbon) ToW3cString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(W3cLayout)
}
// ToUnixDateString outputs a string in "Mon Jan _2 15:04:05 MST 2006" layout.
// 输出 "Mon Jan _2 15:04:05 MST 2006" 格式字符串
func (c Carbon) ToUnixDateString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(UnixDateLayout)
}
// ToRubyDateString outputs a string in "Mon Jan 02 15:04:05 -0700 2006" layout.
// 输出 "Mon Jan 02 15:04:05 -0700 2006" 格式字符串
func (c Carbon) ToRubyDateString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RubyDateLayout)
}
// ToKitchenString outputs a string in "3:04PM" layout.
// 输出 "3:04PM" 格式字符串
func (c Carbon) ToKitchenString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(KitchenLayout)
}
// ToIso8601String outputs a string in "2006-01-02T15:04:05-07:00" layout.
// 输出 "2006-01-02T15:04:05-07:00" 格式字符串
func (c Carbon) ToIso8601String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601Layout)
}
// ToIso8601MilliString outputs a string in "2006-01-02T15:04:05.999-07:00" layout.
// 输出 "2006-01-02T15:04:05.999-07:00" 格式字符串
func (c Carbon) ToIso8601MilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601MilliLayout)
}
// ToIso8601MicroString outputs a string in "2006-01-02T15:04:05.999999-07:00" layout.
// 输出 "2006-01-02T15:04:05.999999-07:00" 格式字符串
func (c Carbon) ToIso8601MicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601MicroLayout)
}
// ToIso8601NanoString outputs a string in "2006-01-02T15:04:05.999999999-07:00" layout.
// 输出 "2006-01-02T15:04:05.999999999-07:00" 格式字符串
func (c Carbon) ToIso8601NanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601NanoLayout)
}
// ToIso8601ZuluString outputs a string in "2006-01-02T15:04:05Z" layout.
// 输出 "2006-01-02T15:04:05Z" 格式字符串
func (c Carbon) ToIso8601ZuluString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601ZuluLayout)
}
// ToIso8601ZuluMilliString outputs a string in "2006-01-02T15:04:05.999Z" layout.
// 输出 "2006-01-02T15:04:05.999Z" 格式字符串
func (c Carbon) ToIso8601ZuluMilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601ZuluMilliLayout)
}
// ToIso8601ZuluMicroString outputs a string in "2006-01-02T15:04:05.999999Z" layout.
// 输出 "2006-01-02T15:04:05.999999Z" 格式字符串
func (c Carbon) ToIso8601ZuluMicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601ZuluMicroLayout)
}
// ToIso8601ZuluNanoString outputs a string in "2006-01-02T15:04:05.999999999Z" layout.
// 输出 "2006-01-02T15:04:05.999999999Z" 格式字符串
func (c Carbon) ToIso8601ZuluNanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(ISO8601ZuluNanoLayout)
}
// ToRfc822String outputs a string in "02 Jan 06 15:04 MST" layout.
// 输出 "02 Jan 06 15:04 MST" 格式字符串
func (c Carbon) ToRfc822String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC822Layout)
}
// ToRfc822zString outputs a string in "02 Jan 06 15:04 -0700" layout.
// 输出 "02 Jan 06 15:04 -0700" 格式字符串
func (c Carbon) ToRfc822zString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC822ZLayout)
}
// ToRfc850String outputs a string in "Monday, 02-Jan-06 15:04:05 MST" layout.
// 输出 "Monday, 02-Jan-06 15:04:05 MST" 格式字符串
func (c Carbon) ToRfc850String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC850Layout)
}
// ToRfc1036String outputs a string in "Mon, 02 Jan 06 15:04:05 -0700" layout.
// 输出 "Mon, 02 Jan 06 15:04:05 -0700" 格式字符串
func (c Carbon) ToRfc1036String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC1036Layout)
}
// ToRfc1123String outputs a string in "Mon, 02 Jan 2006 15:04:05 MST" layout.
// 输出 "Mon, 02 Jan 2006 15:04:05 MST" 格式字符串
func (c Carbon) ToRfc1123String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC1123Layout)
}
// ToRfc1123zString outputs a string in "Mon, 02 Jan 2006 15:04:05 -0700" layout.
// 输出 "Mon, 02 Jan 2006 15:04:05 -0700" 格式字符串
func (c Carbon) ToRfc1123zString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC1123ZLayout)
}
// ToRfc2822String outputs a string in "Mon, 02 Jan 2006 15:04:05 -0700" layout.
// 输出 "Mon, 02 Jan 2006 15:04:05 -0700" 格式字符串
func (c Carbon) ToRfc2822String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC2822Layout)
}
// ToRfc3339String outputs a string in "2006-01-02T15:04:05Z07:00" layout.
// 输出 "2006-01-02T15:04:05Z07:00" 格式字符串
func (c Carbon) ToRfc3339String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC3339Layout)
}
// ToRfc3339MilliString outputs a string in "2006-01-02T15:04:05.999Z07:00" layout.
// 输出 "2006-01-02T15:04:05.999Z07:00" 格式字符串
func (c Carbon) ToRfc3339MilliString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC3339MilliLayout)
}
// ToRfc3339MicroString outputs a string in "2006-01-02T15:04:05.999999Z07:00" layout.
// 输出 "2006-01-02T15:04:05.999999Z07:00" 格式字符串
func (c Carbon) ToRfc3339MicroString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC3339MicroLayout)
}
// ToRfc3339NanoString outputs a string in "2006-01-02T15:04:05.999999999Z07:00" layout.
// 输出 "2006-01-02T15:04:05.999999999Z07:00" 格式字符串
func (c Carbon) ToRfc3339NanoString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC3339NanoLayout)
}
// ToRfc7231String outputs a string in "Mon, 02 Jan 2006 15:04:05 GMT" layout.
// 输出 "Mon, 02 Jan 2006 15:04:05 GMT" 格式字符串
func (c Carbon) ToRfc7231String(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(RFC7231Layout)
}
// ToFormattedDateString outputs a string in "Jan 2, 2006" layout.
// 输出 "Jan 2, 2006" 格式字符串
func (c Carbon) ToFormattedDateString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(FormattedDateLayout)
}
// ToFormattedDayDateString outputs a string in "Mon, Jan 2, 2006" layout.
// 输出 "Jan 2, 2006" 格式字符串
func (c Carbon) ToFormattedDayDateString(timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(FormattedDayDateLayout)
}
// Layout outputs a string by layout.
// 输出指定布局模板的时间字符串
func (c Carbon) Layout(layout string, timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
return c.StdTime().Format(layout)
}
// Format outputs a string by format.
// 输出指定格式模板的时间字符串
func (c Carbon) Format(format string, timezone ...string) string {
- if len(timezone) > 0 {
- c.loc, c.Error = getLocationByTimezone(timezone[0])
- }
if c.IsInvalid() {
return ""
}
+ if len(timezone) > 0 {
+ c.loc, c.Error = getLocationByTimezone(timezone[0])
+ }
buffer := bytes.NewBuffer(nil)
for i := 0; i < len(format); i++ {
if layout, ok := formats[format[i]]; ok {
@@ -898,11 +890,3 @@ func (c Carbon) Format(format string, timezone ...string) string {
}
return buffer.String()
}
-
-// Deprecated: it will be removed in the future, use StdTime instead.
-//
-// ToStdTime converts Carbon to standard time.Time.
-// 将 Carbon 转换成标准 time.Time
-func (c Carbon) ToStdTime() time.Time {
- return c.StdTime()
-}
diff --git a/vendor/github.com/golang-module/carbon/v2/parser.go b/vendor/github.com/dromara/carbon/v2/parser.go
similarity index 92%
rename from vendor/github.com/golang-module/carbon/v2/parser.go
rename to vendor/github.com/dromara/carbon/v2/parser.go
index ec286913..86517f59 100644
--- a/vendor/github.com/golang-module/carbon/v2/parser.go
+++ b/vendor/github.com/dromara/carbon/v2/parser.go
@@ -8,7 +8,8 @@ import (
// Parse parses a standard time string as a Carbon instance.
// 将标准格式时间字符串解析成 Carbon 实例
func (c Carbon) Parse(value string, timezone ...string) Carbon {
- if value == "" || value == "0" || value == "0000-00-00 00:00:00" || value == "0000-00-00" || value == "00:00:00" {
+ if len(value) == 0 {
+ c.Error = invalidValueError(value)
return c
}
if len(timezone) > 0 {
@@ -58,14 +59,18 @@ func ParseByFormat(value, format string, timezone ...string) Carbon {
// ParseByLayout parses a time string as a Carbon instance by layout.
// 通过布局模板将时间字符串解析成 Carbon 实例
func (c Carbon) ParseByLayout(value, layout string, timezone ...string) Carbon {
+ if len(value) == 0 {
+ c.Error = invalidValueError(value)
+ return c
+ }
if len(timezone) > 0 {
c.loc, c.Error = getLocationByTimezone(timezone[0])
}
if c.Error != nil {
return c
}
- if value == "" || value == "0" || value == "0000-00-00 00:00:00" || value == "0000-00-00" || value == "00:00:00" {
- return c
+ if len(layout) == 0 {
+ layout = defaultLayout
}
if layout == "timestamp" {
timestamp, _ := strconv.ParseInt(value, 10, 64)
diff --git a/vendor/github.com/golang-module/carbon/v2/season.go b/vendor/github.com/dromara/carbon/v2/season.go
similarity index 92%
rename from vendor/github.com/golang-module/carbon/v2/season.go
rename to vendor/github.com/dromara/carbon/v2/season.go
index ceb6ede5..76402c75 100644
--- a/vendor/github.com/golang-module/carbon/v2/season.go
+++ b/vendor/github.com/dromara/carbon/v2/season.go
@@ -24,7 +24,7 @@ var seasons = []struct {
// Season gets season name according to the meteorological division method like "Spring", i18n is supported.
// 获取当前季节(以气象划分),支持i18n
func (c Carbon) Season() string {
- if c.IsInvalid() {
+ if c.Error != nil {
return ""
}
if len(c.lang.resources) == 0 {
@@ -38,8 +38,8 @@ func (c Carbon) Season() string {
index = season.index
}
}
- c.lang.rw.Lock()
- defer c.lang.rw.Unlock()
+ c.lang.rw.RLock()
+ defer c.lang.rw.RUnlock()
if resources, ok := c.lang.resources["seasons"]; ok {
slice := strings.Split(resources, "|")
if len(slice) == QuartersPerYear {
@@ -52,7 +52,7 @@ func (c Carbon) Season() string {
// StartOfSeason returns a Carbon instance for start of the season.
// 本季节开始时间
func (c Carbon) StartOfSeason() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, _ := c.Date()
@@ -65,7 +65,7 @@ func (c Carbon) StartOfSeason() Carbon {
// EndOfSeason returns a Carbon instance for end of the season.
// 本季节结束时间
func (c Carbon) EndOfSeason() Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, _ := c.Date()
@@ -81,7 +81,7 @@ func (c Carbon) EndOfSeason() Carbon {
// IsSpring reports whether is spring.
// 是否是春季
func (c Carbon) IsSpring() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
month := c.Month()
@@ -94,7 +94,7 @@ func (c Carbon) IsSpring() bool {
// IsSummer reports whether is summer.
// 是否是夏季
func (c Carbon) IsSummer() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
month := c.Month()
@@ -107,7 +107,7 @@ func (c Carbon) IsSummer() bool {
// IsAutumn reports whether is autumn.
// 是否是秋季
func (c Carbon) IsAutumn() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
month := c.Month()
@@ -120,7 +120,7 @@ func (c Carbon) IsAutumn() bool {
// IsWinter reports whether is winter.
// 是否是冬季
func (c Carbon) IsWinter() bool {
- if c.IsInvalid() {
+ if c.Error != nil {
return false
}
month := c.Month()
diff --git a/vendor/github.com/golang-module/carbon/v2/setter.go b/vendor/github.com/dromara/carbon/v2/setter.go
similarity index 93%
rename from vendor/github.com/golang-module/carbon/v2/setter.go
rename to vendor/github.com/dromara/carbon/v2/setter.go
index e66a94aa..6ecbf763 100644
--- a/vendor/github.com/golang-module/carbon/v2/setter.go
+++ b/vendor/github.com/dromara/carbon/v2/setter.go
@@ -80,7 +80,7 @@ func SetLocale(locale string) Carbon {
// SetDateTime sets year, month, day, hour, minute and second.
// 设置年、月、日、时、分、秒
func (c Carbon) SetDateTime(year, month, day, hour, minute, second int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(year, month, day, hour, minute, second, c.Nanosecond())
@@ -89,7 +89,7 @@ func (c Carbon) SetDateTime(year, month, day, hour, minute, second int) Carbon {
// SetDateTimeMilli sets year, month, day, hour, minute, second and millisecond.
// 设置年、月、日、时、分、秒、毫秒
func (c Carbon) SetDateTimeMilli(year, month, day, hour, minute, second, millisecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(year, month, day, hour, minute, second, millisecond*1e6)
@@ -98,7 +98,7 @@ func (c Carbon) SetDateTimeMilli(year, month, day, hour, minute, second, millise
// SetDateTimeMicro sets year, month, day, hour, minute, second and microsecond.
// 设置年、月、日、时、分、秒、微秒
func (c Carbon) SetDateTimeMicro(year, month, day, hour, minute, second, microsecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(year, month, day, hour, minute, second, microsecond*1e3)
@@ -107,7 +107,7 @@ func (c Carbon) SetDateTimeMicro(year, month, day, hour, minute, second, microse
// SetDateTimeNano sets year, month, day, hour, minute, second and nanosecond.
// 设置年、月、日、时、分、秒、纳秒
func (c Carbon) SetDateTimeNano(year, month, day, hour, minute, second, nanosecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.create(year, month, day, hour, minute, second, nanosecond)
@@ -116,7 +116,7 @@ func (c Carbon) SetDateTimeNano(year, month, day, hour, minute, second, nanoseco
// SetDate sets year, month and day.
// 设置年、月、日
func (c Carbon) SetDate(year, month, day int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
hour, minute, second := c.Time()
@@ -126,7 +126,7 @@ func (c Carbon) SetDate(year, month, day int) Carbon {
// SetDateMilli sets year, month, day and millisecond.
// 设置年、月、日、毫秒
func (c Carbon) SetDateMilli(year, month, day, millisecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
hour, minute, second := c.Time()
@@ -136,7 +136,7 @@ func (c Carbon) SetDateMilli(year, month, day, millisecond int) Carbon {
// SetDateMicro sets year, month, day and microsecond.
// 设置年、月、日、微秒
func (c Carbon) SetDateMicro(year, month, day, microsecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
hour, minute, second := c.Time()
@@ -146,7 +146,7 @@ func (c Carbon) SetDateMicro(year, month, day, microsecond int) Carbon {
// SetDateNano sets year, month, day and nanosecond.
// 设置年、月、日、纳秒
func (c Carbon) SetDateNano(year, month, day, nanosecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
hour, minute, second := c.Time()
@@ -156,7 +156,7 @@ func (c Carbon) SetDateNano(year, month, day, nanosecond int) Carbon {
// SetTime sets hour, minute and second.
// 设置时、分、秒
func (c Carbon) SetTime(hour, minute, second int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -166,7 +166,7 @@ func (c Carbon) SetTime(hour, minute, second int) Carbon {
// SetTimeMilli sets hour, minute, second and millisecond.
// 设置时、分、秒、毫秒
func (c Carbon) SetTimeMilli(hour, minute, second, millisecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -176,7 +176,7 @@ func (c Carbon) SetTimeMilli(hour, minute, second, millisecond int) Carbon {
// SetTimeMicro sets hour, minute, second and microsecond.
// 设置时、分、秒、微秒
func (c Carbon) SetTimeMicro(hour, minute, second, microsecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -186,7 +186,7 @@ func (c Carbon) SetTimeMicro(hour, minute, second, microsecond int) Carbon {
// SetTimeNano sets hour, minute, second and nanosecond.
// 设置、时、分、秒、纳秒
func (c Carbon) SetTimeNano(hour, minute, second, nanosecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day := c.Date()
@@ -196,7 +196,7 @@ func (c Carbon) SetTimeNano(hour, minute, second, nanosecond int) Carbon {
// SetYear sets year.
// 设置年份
func (c Carbon) SetYear(year int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
_, month, day, hour, minute, second := c.DateTime()
@@ -206,7 +206,7 @@ func (c Carbon) SetYear(year int) Carbon {
// SetYearNoOverflow sets year without overflowing month.
// 设置年份(月份不溢出)
func (c Carbon) SetYearNoOverflow(year int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.AddYearsNoOverflow(year - c.Year())
@@ -215,7 +215,7 @@ func (c Carbon) SetYearNoOverflow(year int) Carbon {
// SetMonth sets month.
// 设置月份
func (c Carbon) SetMonth(month int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, _, day, hour, minute, second := c.DateTime()
@@ -225,7 +225,7 @@ func (c Carbon) SetMonth(month int) Carbon {
// SetMonthNoOverflow sets month without overflowing month.
// 设置月份(月份不溢出)
func (c Carbon) SetMonthNoOverflow(month int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
return c.AddMonthsNoOverflow(month - c.Month())
@@ -234,7 +234,7 @@ func (c Carbon) SetMonthNoOverflow(month int) Carbon {
// SetDay sets day.
// 设置日期
func (c Carbon) SetDay(day int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, _, hour, minute, second := c.DateTime()
@@ -244,7 +244,7 @@ func (c Carbon) SetDay(day int) Carbon {
// SetHour sets hour.
// 设置小时
func (c Carbon) SetHour(hour int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, _, minute, second := c.DateTime()
@@ -254,7 +254,7 @@ func (c Carbon) SetHour(hour int) Carbon {
// SetMinute sets minute.
// 设置分钟
func (c Carbon) SetMinute(minute int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, _, second := c.DateTime()
@@ -264,7 +264,7 @@ func (c Carbon) SetMinute(minute int) Carbon {
// SetSecond sets second.
// 设置秒数
func (c Carbon) SetSecond(second int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, _ := c.DateTime()
@@ -274,7 +274,7 @@ func (c Carbon) SetSecond(second int) Carbon {
// SetMillisecond sets millisecond.
// 设置毫秒
func (c Carbon) SetMillisecond(millisecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, second := c.DateTime()
@@ -284,7 +284,7 @@ func (c Carbon) SetMillisecond(millisecond int) Carbon {
// SetMicrosecond sets microsecond.
// 设置微秒
func (c Carbon) SetMicrosecond(microsecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, second := c.DateTime()
@@ -294,7 +294,7 @@ func (c Carbon) SetMicrosecond(microsecond int) Carbon {
// SetNanosecond sets nanosecond.
// 设置纳秒
func (c Carbon) SetNanosecond(nanosecond int) Carbon {
- if c.IsInvalid() {
+ if c.Error != nil {
return c
}
year, month, day, hour, minute, second := c.DateTime()
diff --git a/vendor/github.com/golang-module/carbon/v2/test.go b/vendor/github.com/dromara/carbon/v2/test.go
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/test.go
rename to vendor/github.com/dromara/carbon/v2/test.go
diff --git a/vendor/github.com/golang-module/carbon/v2/traveler.go b/vendor/github.com/dromara/carbon/v2/traveler.go
similarity index 100%
rename from vendor/github.com/golang-module/carbon/v2/traveler.go
rename to vendor/github.com/dromara/carbon/v2/traveler.go
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.cn.md b/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.cn.md
deleted file mode 100644
index 5a8f9df8..00000000
--- a/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.cn.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# 波斯历(伊朗历)
-
-简体中文 | [English](README.md) | [日本語](README.jp.md)
-
-#### 用法示例
-
-##### 将 `公历` 转换成 `波斯历`
-
-```go
-// 获取波斯历年份
-carbon.Parse("2020-08-05 13:14:15").Persian().Year() // 1399
-// 获取波斯历月份
-carbon.Parse("2020-08-05 13:14:15").Persian().Month() // 5
-// 获取波斯历日期
-carbon.Parse("2020-08-05 13:14:15").Persian().Day() // 15
-// 获取波斯历小时
-carbon.Parse("2020-08-05 13:14:15").Persian().Hour() // 13
-// 获取波斯历分钟
-carbon.Parse("2020-08-05 13:14:15").Lunar().Minute() // 14
-// 获取波斯历秒数
-carbon.Parse("2020-08-05 13:14:15").Lunar().Second() // 15
-
-// 获取波斯历日期时间字符串
-carbon.Parse("2020-08-05 13:14:15").Lunar().String() // 1399-05-15 13:14:15
-fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15").Lunar()) // 1399-05-15 13:14:15
-// 获取波斯历月字符串
-carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString() // مرداد
-// 获取波斯历周字符串
-carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString() // چهارشنبه
-
-// 是否是波斯历零值时间
-carbon.Parse("0000-00-00 00:00:00").Persian().IsZero() // true
-carbon.Parse("2020-08-05 13:14:15").Persian().IsZero() // false
-
-// 是否是波斯历闰年
-carbon.Parse("2016-03-20 00:00:00").Persian().IsLeapYear() // true
-carbon.Parse("2020-08-05 13:14:15").Persian().IsLeapYear() // false
-```
-
-##### 将 `波斯历` 转化成 `公历`
-
-```go
-carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
-carbon.CreateFromPersian(1399, 5, 15, 13, 14, 15).ToDateTimeString() // 2020-08-05 13:14:15
-```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.jp.md b/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.jp.md
deleted file mode 100644
index 337fb95e..00000000
--- a/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.jp.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# ペルシア暦(イラン暦)
-
-日本語 | [English](README.md) | [简体中文](README.cn.md)
-
-#### 使い方の例
-
-##### `西暦` を `ペルシャ暦` に変換
-
-```go
-// ペルシャ暦の取得
-carbon.Parse("2020-08-05 13:14:15").Persian().Year() // 1399
-// ペルシャ暦月の取得
-carbon.Parse("2020-08-05 13:14:15").Persian().Month() // 5
-// ペルシャ暦の取得日
-carbon.Parse("2020-08-05 13:14:15").Persian().Day() // 15
-// ペルシャ暦時間の取得
-carbon.Parse("2020-08-05 13:14:15").Persian().Hour() // 13
-// ペルシャ暦分の取得
-carbon.Parse("2020-08-05 13:14:15").Lunar().Minute() // 14
-// ペルシャ暦秒の取得
-carbon.Parse("2020-08-05 13:14:15").Lunar().Second() // 15
-
-// ペルシャ暦日時文字列の取得
-carbon.Parse("2020-08-05 13:14:15").Lunar().String() // 1399-05-15 13:14:15
-fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15").Lunar()) // 1399-05-15 13:14:15
-// ペルシア暦月文字列の取得
-carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString() // مرداد
-// ペルシャ暦週文字列の取得
-carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString() // چهارشنبه
-
-// ペルシャ暦ゼロ時間かどうか
-carbon.Parse("0000-00-00 00:00:00").Persian().IsZero() // true
-carbon.Parse("2020-08-05 13:14:15").Persian().IsZero() // false
-
-// ペルシア暦閏年かどうか
-carbon.Parse("2016-03-20 00:00:00").Persian().IsLeapYear() // true
-carbon.Parse("2020-08-05 13:14:15").Persian().IsLeapYear() // false
-```
-
-##### ペルシャ暦を西暦に変換する
-
-```go
-carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
-carbon.CreateFromPersian(1399, 5, 15, 13, 14, 15).ToDateTimeString() // 2020-08-05 13:14:15
-```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.md b/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.md
deleted file mode 100644
index c44dc452..00000000
--- a/vendor/github.com/golang-module/carbon/v2/calendar/persian/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# Persian(Jalaali) Calendar
-
-English | [简体中文](README.cn.md) | [日本語](README.jp.md)
-
-#### Usage and example
-
-##### Convert `Gregorian` calendar to `Persian` calendar
-
-```go
-// Get persian year
-carbon.Parse("2020-08-05 13:14:15").Persian().Year() // 1399
-// Get persian month
-carbon.Parse("2020-08-05 13:14:15").Persian().Month() // 5
-// Get persian day
-carbon.Parse("2020-08-05 13:14:15").Persian().Day() // 15
-// Get persian hour
-carbon.Parse("2020-08-05 13:14:15").Persian().Hour() // 13
-// Get persian minute
-carbon.Parse("2020-08-05 13:14:15").Lunar().Minute() // 14
-// Get persian second
-carbon.Parse("2020-08-05 13:14:15").Lunar().Second() // 15
-
-// Get persian date and time string
-carbon.Parse("2020-08-05 13:14:15").Lunar().String() // 1399-05-15 13:14:15
-fmt.Printf("%s", carbon.Parse("2020-08-05 13:14:15").Lunar()) // 1399-05-15 13:14:15
-// // Get persian month as string
-carbon.Parse("2020-08-05 13:14:15").Persian().ToMonthString() // مرداد
-// // Get persian week as string
-carbon.Parse("2020-08-05 13:14:15").Persian().ToWeekString() // چهارشنبه
-
-// Whether is a persian zero time
-carbon.Parse("0000-00-00 00:00:00").Persian().IsZero() // true
-carbon.Parse("2020-08-05 13:14:15").Persian().IsZero() // false
-
-// Whether is a persian leap year
-carbon.Parse("2016-03-20 00:00:00").Persian().IsLeapYear() // true
-carbon.Parse("2020-08-05 13:14:15").Persian().IsLeapYear() // false
-```
-
-##### Convert `Persian` calendar to `Gregorian` calendar
-
-```go
-carbon.CreateFromPersian(1395, 1, 1, 0, 0, 0).ToDateTimeString() // 2016-03-20 00:00:00
-carbon.CreateFromPersian(1399, 5, 15, 13, 14, 15).ToDateTimeString() // 2020-08-05 13:14:15
-```
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/database.go b/vendor/github.com/golang-module/carbon/v2/database.go
deleted file mode 100644
index 05802ac8..00000000
--- a/vendor/github.com/golang-module/carbon/v2/database.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package carbon
-
-import (
- "database/sql/driver"
- "fmt"
- "time"
-)
-
-// Scan an interface used by Scan in package database/sql for Scanning value from database to local golang variable.
-func (c *Carbon) Scan(v interface{}) error {
- if value, ok := v.(time.Time); ok {
- loc, err := getLocationByTimezone(defaultTimezone)
- if c.loc != nil {
- loc = c.loc
- }
- *c = CreateFromStdTime(value)
- c.loc, c.Error = loc, err
- return nil
- }
- return fmt.Errorf("can not convert %v to carbon", v)
-}
-
-// Value the interface providing the Value method for package database/sql/driver.
-func (c Carbon) Value() (driver.Value, error) {
- if c.IsZero() {
- return nil, nil
- }
- return c.StdTime(), nil
-}
-
-// GormDataType implements the interface GormDataTypeInterface for Carbon struct.
-// 实现 GormDataTypeInterface 接口
-func (c Carbon) GormDataType() string {
- return "time"
-}
diff --git a/vendor/github.com/golang-module/carbon/v2/encoding.go b/vendor/github.com/golang-module/carbon/v2/encoding.go
deleted file mode 100644
index 0c8a73fa..00000000
--- a/vendor/github.com/golang-module/carbon/v2/encoding.go
+++ /dev/null
@@ -1,52 +0,0 @@
-package carbon
-
-import (
- "bytes"
- "fmt"
-)
-
-// MarshalJSON implements the json.Marshaler interface.
-// 实现 json.Marshaler 接口
-func (c Carbon) MarshalJSON() ([]byte, error) {
- if c.Error != nil {
- return nil, c.Error
- }
- key, value, tz := c.parseTag()
- data := ""
- if key == "layout" {
- data = fmt.Sprintf(`"%s"`, c.Layout(value, tz))
- }
- if key == "format" {
- // timestamp without double quotes in json
- if value == "U" || value == "V" || value == "X" || value == "Z" {
- data = fmt.Sprintf(`%s`, c.Format(value, tz))
- } else {
- data = fmt.Sprintf(`"%s"`, c.Format(value, tz))
- }
- }
- return []byte(data), nil
-}
-
-// UnmarshalJSON implements the json.Unmarshaler interface.
-// 实现 json.Unmarshaler 接口
-func (c *Carbon) UnmarshalJSON(b []byte) error {
- if c.Error != nil {
- return c.Error
- }
- if len(b) == 0 || string(b) == "null" {
- return nil
- }
- key, value, tz := c.parseTag()
- data := fmt.Sprintf("%s", bytes.Trim(b, `"`))
- if key == "layout" {
- *c = ParseByLayout(data, value, tz)
- }
- if key == "format" {
- *c = ParseByFormat(data, value, tz)
- }
- c.tag = &tag{
- carbon: fmt.Sprintf("%s:%s", key, value),
- tz: tz,
- }
- return c.Error
-}
diff --git a/vendor/github.com/golang-module/carbon/v2/lang/fa.json b/vendor/github.com/golang-module/carbon/v2/lang/fa.json
deleted file mode 100644
index f5ffc2b8..00000000
--- a/vendor/github.com/golang-module/carbon/v2/lang/fa.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "Farsi",
- "months": "دسامبر|نوامبر|اکتبر|سپتامبر|اوت|ژوئیه|ژوئن|مه|آوریل|مارس|فوریه|ژانویه",
- "short_months": "دسامبر|نوامبر|اکتبر|سپتامبر|اوت|ژوئیه|ژوئن|مه|آوریل|مارس|فوریه|ژانویه",
- "weeks": "شنبه|جمعه|پنجشنبه|چهارشنبه|سه شنبه|دوشنبه|یکشنبه",
- "short_weeks": "شنبه|جمعه|پنجشنبه|چهارشنبه|سه شنبه|دوشنبه|یکشنبه",
- "seasons": "زمستان|پاییز|تابستان|بهار",
- "constellations": "ماهی|آبریز|بز|کمان|عقرب|ترازو|خوشه|شیر|خرچنگ|دوپیکر|گاو نر|قوچ",
- "year": "سال|۱ سال %d",
- "month": "ماه|۱ ماه %d",
- "week": "هفته|۱ هفته %d",
- "day": "روز|۱ روز %d",
- "hour": "ساعت|۱ ساعت %d",
- "minute": "دقیقه|۱ دقیقه %d",
- "second": "ثانیه|۱ ثانیه %d",
- "now": "الان",
- "ago": "قبل %s",
- "from_now": "از الان %s",
- "before": "قبل %s",
- "after": "بعد %s"
-}
\ No newline at end of file
diff --git a/vendor/github.com/golang-module/carbon/v2/tag.go b/vendor/github.com/golang-module/carbon/v2/tag.go
deleted file mode 100644
index 8ca0e9f8..00000000
--- a/vendor/github.com/golang-module/carbon/v2/tag.go
+++ /dev/null
@@ -1,160 +0,0 @@
-package carbon
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-var (
- // supported types
- // 支持的类型
- tagTypes = map[string]string{
- "dateTime": "layout:" + DateTimeLayout,
- "dateTimeMilli": "layout:" + DateTimeMilliLayout,
- "dateTimeMicro": "layout:" + DateTimeMicroLayout,
- "dateTimeNano": "layout:" + DateTimeNanoLayout,
- "shortDateTime": "layout:" + ShortDateTimeLayout,
- "shortDateTimeMilli": "layout:" + ShortDateTimeMilliLayout,
- "shortDateTimeMicro": "layout:" + ShortDateTimeMicroLayout,
- "shortDateTimeNano": "layout:" + ShortDateTimeNanoLayout,
- "dayDateTime": "layout:" + DayDateTimeLayout,
-
- "date": "layout:" + DateLayout,
- "dateMilli": "layout:" + DateMilliLayout,
- "dateMicro": "layout:" + DateMicroLayout,
- "dateNano": "layout:" + DateNanoLayout,
- "shortDate": "layout:" + ShortDateLayout,
- "shortDateMilli": "layout:" + ShortDateMilliLayout,
- "shortDateMicro": "layout:" + ShortDateMicroLayout,
- "shortDateNano": "layout:" + ShortDateNanoLayout,
-
- "time": "layout:" + TimeLayout,
- "timeMilli": "layout:" + TimeMilliLayout,
- "timeMicro": "layout:" + TimeMicroLayout,
- "timeNano": "layout:" + TimeNanoLayout,
- "shortTime": "layout:" + ShortTimeLayout,
- "shortTimeMilli": "layout:" + ShortTimeMilliLayout,
- "shortTimeMicro": "layout:" + ShortTimeMicroLayout,
- "shortTimeNano": "layout:" + ShortTimeNanoLayout,
-
- "atom": "layout:" + AtomLayout,
- "ansic": "layout:" + ANSICLayout,
- "cookie": "layout:" + CookieLayout,
- "kitchen": "layout:" + KitchenLayout,
- "rss": "layout:" + RssLayout,
- "rubyDate": "layout:" + RubyDateLayout,
- "unixDate": "layout:" + UnixDateLayout,
-
- "rfc1036": "layout:" + RFC1036Layout,
- "rfc1123": "layout:" + RFC1123Layout,
- "rfc1123Z": "layout:" + RFC1123ZLayout,
- "rfc2822": "layout:" + RFC2822Layout,
- "rfc3339": "layout:" + RFC3339Layout,
- "rfc3339Milli": "layout:" + RFC3339MilliLayout,
- "rfc3339Micro": "layout:" + RFC3339MicroLayout,
- "rfc3339Nano": "layout:" + RFC3339NanoLayout,
- "rfc7231": "layout:" + RFC7231Layout,
- "rfc822": "layout:" + RFC822Layout,
- "rfc822Z": "layout:" + RFC822ZLayout,
- "rfc850": "layout:" + RFC850Layout,
-
- "iso8601": "layout:" + ISO8601Layout,
- "iso8601Milli": "layout:" + ISO8601MilliLayout,
- "iso8601Micro": "layout:" + ISO8601MicroLayout,
- "iso8601Nano": "layout:" + ISO8601NanoLayout,
-
- "timestamp": "format:U",
- "timestampMilli": "format:V",
- "timestampMicro": "format:X",
- "timestampNano": "format:Z",
- }
-
- // invalid pointer error
- // 无效的指针错误
- invalidPtrError = func() error {
- return fmt.Errorf("invalid struct pointer, please make sure the struct is a pointer")
- }
-
- // invalid tag error
- // 无效的标签错误
- invalidTagError = func(field string) error {
- return fmt.Errorf("invalid carbon tag in %s field, please make sure the tag is valid", field)
- }
-)
-
-// tag defines a tag struct.
-// 定义 tag 结构体
-type tag struct {
- carbon string
- tz string
-}
-
-// SetTag sets tag.
-// 设置标签
-func (c Carbon) SetTag(tag *tag) Carbon {
- if c.Error != nil {
- return c
- }
- c.tag = tag
- return c
-}
-
-// parseTag parses tag.
-// 解析标签
-func (c Carbon) parseTag() (key, value, tz string) {
- if c.tag == nil {
- return "layout", defaultLayout, defaultTimezone
- }
- tz = strings.TrimSpace(c.tag.tz)
- if tz == "" {
- tz = defaultTimezone
- }
- carbon := strings.TrimSpace(c.tag.carbon)
- if carbon == "" {
- return "layout", defaultLayout, tz
- }
- if !strings.HasPrefix(carbon, "layout:") && !strings.HasPrefix(carbon, "format:") {
- return "", "", tz
- }
- key = strings.TrimSpace(carbon[:6])
- value = strings.TrimSpace(carbon[7:])
- return
-}
-
-// LoadTag loads tag.
-// 加载标签
-func LoadTag(v interface{}) error {
- typeObj, valueObj := reflect.TypeOf(v), reflect.ValueOf(v)
- if typeObj.Kind() != reflect.Ptr {
- return invalidPtrError()
- }
- typeElem, valueElem := typeObj.Elem(), valueObj.Elem()
- params := make([]reflect.Value, 1)
- for i := 0; i < valueElem.NumField(); i++ {
- fieldType, fieldValue := typeElem.Field(i), valueElem.Field(i)
- if reflect.TypeOf(Carbon{}) != fieldValue.Type() {
- continue
- }
- carbon := fieldType.Tag.Get("carbon")
- if carbon == "" {
- carbon = "layout:" + defaultLayout
- }
- if strings.HasPrefix(carbon, "type:") {
- carbon = tagTypes[carbon[5:]]
- }
- if !strings.HasPrefix(carbon, "layout:") && !strings.HasPrefix(carbon, "format:") {
- return invalidTagError(fieldType.Name)
- }
- tz := fieldType.Tag.Get("tz")
- if tz == "" {
- tz = defaultTimezone
- }
- params[0] = reflect.ValueOf(&tag{
- carbon: carbon,
- tz: tz,
- })
- fieldValue.Set(fieldValue.MethodByName("SetTag").Call(params)[0])
- }
- return nil
-}
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/vendor/github.com/stretchr/testify/assert/assertion_compare.go
index 4d4b4aad..7e19eba0 100644
--- a/vendor/github.com/stretchr/testify/assert/assertion_compare.go
+++ b/vendor/github.com/stretchr/testify/assert/assertion_compare.go
@@ -7,10 +7,13 @@ import (
"time"
)
-type CompareType int
+// Deprecated: CompareType has only ever been for internal use and has accidentally been published since v1.6.0. Do not use it.
+type CompareType = compareResult
+
+type compareResult int
const (
- compareLess CompareType = iota - 1
+ compareLess compareResult = iota - 1
compareEqual
compareGreater
)
@@ -39,7 +42,7 @@ var (
bytesType = reflect.TypeOf([]byte{})
)
-func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
+func compare(obj1, obj2 interface{}, kind reflect.Kind) (compareResult, bool) {
obj1Value := reflect.ValueOf(obj1)
obj2Value := reflect.ValueOf(obj2)
@@ -325,7 +328,13 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
}
- return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64)
+ if timeObj1.Before(timeObj2) {
+ return compareLess, true
+ }
+ if timeObj1.Equal(timeObj2) {
+ return compareEqual, true
+ }
+ return compareGreater, true
}
case reflect.Slice:
{
@@ -345,7 +354,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
}
- return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
+ return compareResult(bytes.Compare(bytesObj1, bytesObj2)), true
}
case reflect.Uintptr:
{
@@ -381,7 +390,7 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
if h, ok := t.(tHelper); ok {
h.Helper()
}
- return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
+ return compareTwoValues(t, e1, e2, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
}
// GreaterOrEqual asserts that the first element is greater than or equal to the second
@@ -394,7 +403,7 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
if h, ok := t.(tHelper); ok {
h.Helper()
}
- return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
+ return compareTwoValues(t, e1, e2, []compareResult{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
}
// Less asserts that the first element is less than the second
@@ -406,7 +415,7 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
if h, ok := t.(tHelper); ok {
h.Helper()
}
- return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
+ return compareTwoValues(t, e1, e2, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
}
// LessOrEqual asserts that the first element is less than or equal to the second
@@ -419,7 +428,7 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
if h, ok := t.(tHelper); ok {
h.Helper()
}
- return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
+ return compareTwoValues(t, e1, e2, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
}
// Positive asserts that the specified element is positive
@@ -431,7 +440,7 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
h.Helper()
}
zero := reflect.Zero(reflect.TypeOf(e))
- return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
+ return compareTwoValues(t, e, zero.Interface(), []compareResult{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
}
// Negative asserts that the specified element is negative
@@ -443,10 +452,10 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
h.Helper()
}
zero := reflect.Zero(reflect.TypeOf(e))
- return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...)
+ return compareTwoValues(t, e, zero.Interface(), []compareResult{compareLess}, "\"%v\" is not negative", msgAndArgs...)
}
-func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
+func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
@@ -469,7 +478,7 @@ func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedCompare
return true
}
-func containsValue(values []CompareType, value CompareType) bool {
+func containsValue(values []compareResult, value compareResult) bool {
for _, v := range values {
if v == value {
return true
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go
index 3ddab109..19063416 100644
--- a/vendor/github.com/stretchr/testify/assert/assertion_format.go
+++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go
@@ -104,8 +104,8 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
}
-// EqualValuesf asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValuesf asserts that two objects are equal or convertible to the larger
+// type and equal.
//
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
@@ -186,7 +186,7 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -568,6 +568,23 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a
return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
}
+// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
+//
+// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
+//
+// assert.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
+func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
+}
+
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
@@ -604,7 +621,16 @@ func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg s
return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
}
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
+// NotErrorAsf asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
+}
+
+// NotErrorIsf asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go
index a84e09bd..21629087 100644
--- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go
+++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go
@@ -186,8 +186,8 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
}
-// EqualValues asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValues asserts that two objects are equal or convertible to the larger
+// type and equal.
//
// a.EqualValues(uint32(123), int32(123))
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
@@ -197,8 +197,8 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
return EqualValues(a.t, expected, actual, msgAndArgs...)
}
-// EqualValuesf asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValuesf asserts that two objects are equal or convertible to the larger
+// type and equal.
//
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
@@ -336,7 +336,7 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
// a.EventuallyWithT(func(c *assert.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -361,7 +361,7 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1128,6 +1128,40 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin
return NotContainsf(a.t, s, contains, msg, args...)
}
+// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// a.NotElementsMatch([1, 1, 2, 3], [1, 1, 2, 3]) -> false
+//
+// a.NotElementsMatch([1, 1, 2, 3], [1, 2, 3]) -> true
+//
+// a.NotElementsMatch([1, 2, 3], [1, 2, 4]) -> true
+func (a *Assertions) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotElementsMatch(a.t, listA, listB, msgAndArgs...)
+}
+
+// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// a.NotElementsMatchf([1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
+//
+// a.NotElementsMatchf([1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
+//
+// a.NotElementsMatchf([1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
+func (a *Assertions) NotElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotElementsMatchf(a.t, listA, listB, msg, args...)
+}
+
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
@@ -1200,7 +1234,25 @@ func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg str
return NotEqualf(a.t, expected, actual, msg, args...)
}
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
+// NotErrorAs asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotErrorAs(a.t, err, target, msgAndArgs...)
+}
+
+// NotErrorAsf asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func (a *Assertions) NotErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ return NotErrorAsf(a.t, err, target, msg, args...)
+}
+
+// NotErrorIs asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
@@ -1209,7 +1261,7 @@ func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface
return NotErrorIs(a.t, err, target, msgAndArgs...)
}
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
+// NotErrorIsf asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
diff --git a/vendor/github.com/stretchr/testify/assert/assertion_order.go b/vendor/github.com/stretchr/testify/assert/assertion_order.go
index 00df62a0..1d2f7182 100644
--- a/vendor/github.com/stretchr/testify/assert/assertion_order.go
+++ b/vendor/github.com/stretchr/testify/assert/assertion_order.go
@@ -6,7 +6,7 @@ import (
)
// isOrdered checks that collection contains orderable elements.
-func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
+func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
objKind := reflect.TypeOf(object).Kind()
if objKind != reflect.Slice && objKind != reflect.Array {
return false
@@ -50,7 +50,7 @@ func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareT
// assert.IsIncreasing(t, []float{1, 2})
// assert.IsIncreasing(t, []string{"a", "b"})
func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
+ return isOrdered(t, object, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
}
// IsNonIncreasing asserts that the collection is not increasing
@@ -59,7 +59,7 @@ func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo
// assert.IsNonIncreasing(t, []float{2, 1})
// assert.IsNonIncreasing(t, []string{"b", "a"})
func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
+ return isOrdered(t, object, []compareResult{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
}
// IsDecreasing asserts that the collection is decreasing
@@ -68,7 +68,7 @@ func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{})
// assert.IsDecreasing(t, []float{2, 1})
// assert.IsDecreasing(t, []string{"b", "a"})
func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
+ return isOrdered(t, object, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
}
// IsNonDecreasing asserts that the collection is not decreasing
@@ -77,5 +77,5 @@ func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo
// assert.IsNonDecreasing(t, []float{1, 2})
// assert.IsNonDecreasing(t, []string{"a", "b"})
func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
- return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
+ return isOrdered(t, object, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
}
diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go
index 0b7570f2..4e91332b 100644
--- a/vendor/github.com/stretchr/testify/assert/assertions.go
+++ b/vendor/github.com/stretchr/testify/assert/assertions.go
@@ -19,7 +19,9 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/pmezard/go-difflib/difflib"
- "gopkg.in/yaml.v3"
+
+ // Wrapper around gopkg.in/yaml.v3
+ "github.com/stretchr/testify/assert/yaml"
)
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
@@ -45,6 +47,10 @@ type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool
// for table driven tests.
type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool
+// PanicAssertionFunc is a common function prototype when validating a panic value. Can be useful
+// for table driven tests.
+type PanicAssertionFunc = func(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool
+
// Comparison is a custom function that returns true on success and false on failure
type Comparison func() (success bool)
@@ -496,7 +502,13 @@ func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) b
h.Helper()
}
- if !samePointers(expected, actual) {
+ same, ok := samePointers(expected, actual)
+ if !ok {
+ return Fail(t, "Both arguments must be pointers", msgAndArgs...)
+ }
+
+ if !same {
+ // both are pointers but not the same type & pointing to the same address
return Fail(t, fmt.Sprintf("Not same: \n"+
"expected: %p %#v\n"+
"actual : %p %#v", expected, expected, actual, actual), msgAndArgs...)
@@ -516,7 +528,13 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
h.Helper()
}
- if samePointers(expected, actual) {
+ same, ok := samePointers(expected, actual)
+ if !ok {
+ //fails when the arguments are not pointers
+ return !(Fail(t, "Both arguments must be pointers", msgAndArgs...))
+ }
+
+ if same {
return Fail(t, fmt.Sprintf(
"Expected and actual point to the same object: %p %#v",
expected, expected), msgAndArgs...)
@@ -524,21 +542,23 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
return true
}
-// samePointers compares two generic interface objects and returns whether
-// they point to the same object
-func samePointers(first, second interface{}) bool {
+// samePointers checks if two generic interface objects are pointers of the same
+// type pointing to the same object. It returns two values: same indicating if
+// they are the same type and point to the same object, and ok indicating that
+// both inputs are pointers.
+func samePointers(first, second interface{}) (same bool, ok bool) {
firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second)
if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr {
- return false
+ return false, false //not both are pointers
}
firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second)
if firstType != secondType {
- return false
+ return false, true // both are pointers, but of different types
}
// compare pointer addresses
- return first == second
+ return first == second, true
}
// formatUnequalValues takes two values of arbitrary types and returns string
@@ -572,8 +592,8 @@ func truncatingFormat(data interface{}) string {
return value
}
-// EqualValues asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValues asserts that two objects are equal or convertible to the larger
+// type and equal.
//
// assert.EqualValues(t, uint32(123), int32(123))
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
@@ -615,21 +635,6 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ..
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
}
- if aType.Kind() == reflect.Ptr {
- aType = aType.Elem()
- }
- if bType.Kind() == reflect.Ptr {
- bType = bType.Elem()
- }
-
- if aType.Kind() != reflect.Struct {
- return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...)
- }
-
- if bType.Kind() != reflect.Struct {
- return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...)
- }
-
expected = copyExportedFields(expected)
actual = copyExportedFields(actual)
@@ -1170,6 +1175,39 @@ func formatListDiff(listA, listB interface{}, extraA, extraB []interface{}) stri
return msg.String()
}
+// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false
+//
+// assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true
+//
+// assert.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true
+func NotElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if isEmpty(listA) && isEmpty(listB) {
+ return Fail(t, "listA and listB contain the same elements", msgAndArgs)
+ }
+
+ if !isList(t, listA, msgAndArgs...) {
+ return Fail(t, "listA is not a list type", msgAndArgs...)
+ }
+ if !isList(t, listB, msgAndArgs...) {
+ return Fail(t, "listB is not a list type", msgAndArgs...)
+ }
+
+ extraA, extraB := diffLists(listA, listB)
+ if len(extraA) == 0 && len(extraB) == 0 {
+ return Fail(t, "listA and listB contain the same elements", msgAndArgs)
+ }
+
+ return true
+}
+
// Condition uses a Comparison to assert a complex condition.
func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
@@ -1488,6 +1526,9 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd
if err != nil {
return Fail(t, err.Error(), msgAndArgs...)
}
+ if math.IsNaN(actualEpsilon) {
+ return Fail(t, "relative error is NaN", msgAndArgs...)
+ }
if actualEpsilon > epsilon {
return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+
" < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...)
@@ -1611,7 +1652,6 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in
// matchRegexp return true if a specified regexp matches a string.
func matchRegexp(rx interface{}, str interface{}) bool {
-
var r *regexp.Regexp
if rr, ok := rx.(*regexp.Regexp); ok {
r = rr
@@ -1619,7 +1659,14 @@ func matchRegexp(rx interface{}, str interface{}) bool {
r = regexp.MustCompile(fmt.Sprint(rx))
}
- return (r.FindStringIndex(fmt.Sprint(str)) != nil)
+ switch v := str.(type) {
+ case []byte:
+ return r.Match(v)
+ case string:
+ return r.MatchString(v)
+ default:
+ return r.MatchString(fmt.Sprint(v))
+ }
}
@@ -1872,7 +1919,7 @@ var spewConfigStringerEnabled = spew.ConfigState{
MaxDepth: 10,
}
-type tHelper interface {
+type tHelper = interface {
Helper()
}
@@ -1911,6 +1958,9 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
// CollectT implements the TestingT interface and collects all errors.
type CollectT struct {
+ // A slice of errors. Non-nil slice denotes a failure.
+ // If it's non-nil but len(c.errors) == 0, this is also a failure
+ // obtained by direct c.FailNow() call.
errors []error
}
@@ -1919,9 +1969,10 @@ func (c *CollectT) Errorf(format string, args ...interface{}) {
c.errors = append(c.errors, fmt.Errorf(format, args...))
}
-// FailNow panics.
-func (*CollectT) FailNow() {
- panic("Assertion failed")
+// FailNow stops execution by calling runtime.Goexit.
+func (c *CollectT) FailNow() {
+ c.fail()
+ runtime.Goexit()
}
// Deprecated: That was a method for internal usage that should not have been published. Now just panics.
@@ -1934,6 +1985,16 @@ func (*CollectT) Copy(TestingT) {
panic("Copy() is deprecated")
}
+func (c *CollectT) fail() {
+ if !c.failed() {
+ c.errors = []error{} // Make it non-nil to mark a failure.
+ }
+}
+
+func (c *CollectT) failed() bool {
+ return c.errors != nil
+}
+
// EventuallyWithT asserts that given condition will be met in waitFor time,
// periodically checking target function each tick. In contrast to Eventually,
// it supplies a CollectT to the condition function, so that the condition
@@ -1951,14 +2012,14 @@ func (*CollectT) Copy(TestingT) {
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
var lastFinishedTickErrs []error
- ch := make(chan []error, 1)
+ ch := make(chan *CollectT, 1)
timer := time.NewTimer(waitFor)
defer timer.Stop()
@@ -1978,16 +2039,16 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time
go func() {
collect := new(CollectT)
defer func() {
- ch <- collect.errors
+ ch <- collect
}()
condition(collect)
}()
- case errs := <-ch:
- if len(errs) == 0 {
+ case collect := <-ch:
+ if !collect.failed() {
return true
}
// Keep the errors from the last ended condition, so that they can be copied to t if timeout is reached.
- lastFinishedTickErrs = errs
+ lastFinishedTickErrs = collect.errors
tick = ticker.C
}
}
@@ -2049,7 +2110,7 @@ func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
), msgAndArgs...)
}
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
+// NotErrorIs asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
@@ -2090,6 +2151,24 @@ func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{
), msgAndArgs...)
}
+// NotErrorAs asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if !errors.As(err, target) {
+ return true
+ }
+
+ chain := buildErrorChainString(err)
+
+ return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+
+ "found: %q\n"+
+ "in chain: %s", target, chain,
+ ), msgAndArgs...)
+}
+
func buildErrorChainString(err error) string {
if err == nil {
return ""
diff --git a/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go b/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go
new file mode 100644
index 00000000..baa0cc7d
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go
@@ -0,0 +1,25 @@
+//go:build testify_yaml_custom && !testify_yaml_fail && !testify_yaml_default
+// +build testify_yaml_custom,!testify_yaml_fail,!testify_yaml_default
+
+// Package yaml is an implementation of YAML functions that calls a pluggable implementation.
+//
+// This implementation is selected with the testify_yaml_custom build tag.
+//
+// go test -tags testify_yaml_custom
+//
+// This implementation can be used at build time to replace the default implementation
+// to avoid linking with [gopkg.in/yaml.v3].
+//
+// In your test package:
+//
+// import assertYaml "github.com/stretchr/testify/assert/yaml"
+//
+// func init() {
+// assertYaml.Unmarshal = func (in []byte, out interface{}) error {
+// // ...
+// return nil
+// }
+// }
+package yaml
+
+var Unmarshal func(in []byte, out interface{}) error
diff --git a/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go b/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go
new file mode 100644
index 00000000..b83c6cf6
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go
@@ -0,0 +1,37 @@
+//go:build !testify_yaml_fail && !testify_yaml_custom
+// +build !testify_yaml_fail,!testify_yaml_custom
+
+// Package yaml is just an indirection to handle YAML deserialization.
+//
+// This package is just an indirection that allows the builder to override the
+// indirection with an alternative implementation of this package that uses
+// another implementation of YAML deserialization. This allows to not either not
+// use YAML deserialization at all, or to use another implementation than
+// [gopkg.in/yaml.v3] (for example for license compatibility reasons, see [PR #1120]).
+//
+// Alternative implementations are selected using build tags:
+//
+// - testify_yaml_fail: [Unmarshal] always fails with an error
+// - testify_yaml_custom: [Unmarshal] is a variable. Caller must initialize it
+// before calling any of [github.com/stretchr/testify/assert.YAMLEq] or
+// [github.com/stretchr/testify/assert.YAMLEqf].
+//
+// Usage:
+//
+// go test -tags testify_yaml_fail
+//
+// You can check with "go list" which implementation is linked:
+//
+// go list -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
+// go list -tags testify_yaml_fail -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
+// go list -tags testify_yaml_custom -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
+//
+// [PR #1120]: https://github.com/stretchr/testify/pull/1120
+package yaml
+
+import goyaml "gopkg.in/yaml.v3"
+
+// Unmarshal is just a wrapper of [gopkg.in/yaml.v3.Unmarshal].
+func Unmarshal(in []byte, out interface{}) error {
+ return goyaml.Unmarshal(in, out)
+}
diff --git a/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go b/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go
new file mode 100644
index 00000000..e78f7dfe
--- /dev/null
+++ b/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go
@@ -0,0 +1,18 @@
+//go:build testify_yaml_fail && !testify_yaml_custom && !testify_yaml_default
+// +build testify_yaml_fail,!testify_yaml_custom,!testify_yaml_default
+
+// Package yaml is an implementation of YAML functions that always fail.
+//
+// This implementation can be used at build time to replace the default implementation
+// to avoid linking with [gopkg.in/yaml.v3]:
+//
+// go test -tags testify_yaml_fail
+package yaml
+
+import "errors"
+
+var errNotImplemented = errors.New("YAML functions are not available (see https://pkg.go.dev/github.com/stretchr/testify/assert/yaml)")
+
+func Unmarshal([]byte, interface{}) error {
+ return errNotImplemented
+}
diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go
index 506a82f8..d8921950 100644
--- a/vendor/github.com/stretchr/testify/require/require.go
+++ b/vendor/github.com/stretchr/testify/require/require.go
@@ -34,9 +34,9 @@ func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interfac
// Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
-// assert.Contains(t, "Hello World", "World")
-// assert.Contains(t, ["Hello", "World"], "World")
-// assert.Contains(t, {"Hello": "World"}, "Hello")
+// require.Contains(t, "Hello World", "World")
+// require.Contains(t, ["Hello", "World"], "World")
+// require.Contains(t, {"Hello": "World"}, "Hello")
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -50,9 +50,9 @@ func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...int
// Containsf asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
-// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
-// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
-// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
+// require.Containsf(t, "Hello World", "World", "error message %s", "formatted")
+// require.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
+// require.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -91,7 +91,7 @@ func DirExistsf(t TestingT, path string, msg string, args ...interface{}) {
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
-// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
+// require.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -106,7 +106,7 @@ func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
-// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
+// require.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -120,7 +120,7 @@ func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
-// assert.Empty(t, obj)
+// require.Empty(t, obj)
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -134,7 +134,7 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
-// assert.Emptyf(t, obj, "error message %s", "formatted")
+// require.Emptyf(t, obj, "error message %s", "formatted")
func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -147,7 +147,7 @@ func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
// Equal asserts that two objects are equal.
//
-// assert.Equal(t, 123, 123)
+// require.Equal(t, 123, 123)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
@@ -166,7 +166,7 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...i
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
-// assert.EqualError(t, err, expectedErrorString)
+// require.EqualError(t, err, expectedErrorString)
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -181,7 +181,7 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
-// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
+// require.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -200,8 +200,8 @@ func EqualErrorf(t TestingT, theError error, errString string, msg string, args
// Exported int
// notExported int
// }
-// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
-// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
+// require.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
+// require.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
func EqualExportedValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -220,8 +220,8 @@ func EqualExportedValues(t TestingT, expected interface{}, actual interface{}, m
// Exported int
// notExported int
// }
-// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
-// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
+// require.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
+// require.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -232,10 +232,10 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
t.FailNow()
}
-// EqualValues asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValues asserts that two objects are equal or convertible to the larger
+// type and equal.
//
-// assert.EqualValues(t, uint32(123), int32(123))
+// require.EqualValues(t, uint32(123), int32(123))
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -246,10 +246,10 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg
t.FailNow()
}
-// EqualValuesf asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValuesf asserts that two objects are equal or convertible to the larger
+// type and equal.
//
-// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
+// require.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -262,7 +262,7 @@ func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg stri
// Equalf asserts that two objects are equal.
//
-// assert.Equalf(t, 123, 123, "error message %s", "formatted")
+// require.Equalf(t, 123, 123, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
@@ -280,8 +280,8 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar
// Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
-// if assert.Error(t, err) {
-// assert.Equal(t, expectedError, err)
+// if require.Error(t, err) {
+// require.Equal(t, expectedError, err)
// }
func Error(t TestingT, err error, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -321,7 +321,7 @@ func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...int
// and that the error contains the specified substring.
//
// actualObj, err := SomeFunction()
-// assert.ErrorContains(t, err, expectedErrorSubString)
+// require.ErrorContains(t, err, expectedErrorSubString)
func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -336,7 +336,7 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in
// and that the error contains the specified substring.
//
// actualObj, err := SomeFunction()
-// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
+// require.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -374,8 +374,8 @@ func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface
// Errorf asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
-// if assert.Errorf(t, err, "error message %s", "formatted") {
-// assert.Equal(t, expectedErrorf, err)
+// if require.Errorf(t, err, "error message %s", "formatted") {
+// require.Equal(t, expectedErrorf, err)
// }
func Errorf(t TestingT, err error, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -390,7 +390,7 @@ func Errorf(t TestingT, err error, msg string, args ...interface{}) {
// Eventually asserts that given condition will be met in waitFor time,
// periodically checking target function each tick.
//
-// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
+// require.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -415,10 +415,10 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
// time.Sleep(8*time.Second)
// externalValue = true
// }()
-// assert.EventuallyWithT(t, func(c *assert.CollectT) {
+// require.EventuallyWithT(t, func(c *require.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
-// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// require.True(c, externalValue, "expected 'externalValue' to be true")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -443,10 +443,10 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF
// time.Sleep(8*time.Second)
// externalValue = true
// }()
-// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
+// require.EventuallyWithTf(t, func(c *require.CollectT, "error message %s", "formatted") {
// // add assertions as needed; any assertion failure will fail the current tick
-// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// require.True(c, externalValue, "expected 'externalValue' to be true")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -460,7 +460,7 @@ func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), wait
// Eventuallyf asserts that given condition will be met in waitFor time,
// periodically checking target function each tick.
//
-// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
+// require.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -473,7 +473,7 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
// Exactly asserts that two objects are equal in value and type.
//
-// assert.Exactly(t, int32(123), int64(123))
+// require.Exactly(t, int32(123), int64(123))
func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -486,7 +486,7 @@ func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ..
// Exactlyf asserts that two objects are equal in value and type.
//
-// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
+// require.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -543,7 +543,7 @@ func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
// False asserts that the specified value is false.
//
-// assert.False(t, myBool)
+// require.False(t, myBool)
func False(t TestingT, value bool, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -556,7 +556,7 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) {
// Falsef asserts that the specified value is false.
//
-// assert.Falsef(t, myBool, "error message %s", "formatted")
+// require.Falsef(t, myBool, "error message %s", "formatted")
func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -593,9 +593,9 @@ func FileExistsf(t TestingT, path string, msg string, args ...interface{}) {
// Greater asserts that the first element is greater than the second
//
-// assert.Greater(t, 2, 1)
-// assert.Greater(t, float64(2), float64(1))
-// assert.Greater(t, "b", "a")
+// require.Greater(t, 2, 1)
+// require.Greater(t, float64(2), float64(1))
+// require.Greater(t, "b", "a")
func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -608,10 +608,10 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
// GreaterOrEqual asserts that the first element is greater than or equal to the second
//
-// assert.GreaterOrEqual(t, 2, 1)
-// assert.GreaterOrEqual(t, 2, 2)
-// assert.GreaterOrEqual(t, "b", "a")
-// assert.GreaterOrEqual(t, "b", "b")
+// require.GreaterOrEqual(t, 2, 1)
+// require.GreaterOrEqual(t, 2, 2)
+// require.GreaterOrEqual(t, "b", "a")
+// require.GreaterOrEqual(t, "b", "b")
func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -624,10 +624,10 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
// GreaterOrEqualf asserts that the first element is greater than or equal to the second
//
-// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
-// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
+// require.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
+// require.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
+// require.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
+// require.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -640,9 +640,9 @@ func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, arg
// Greaterf asserts that the first element is greater than the second
//
-// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
-// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
-// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
+// require.Greaterf(t, 2, 1, "error message %s", "formatted")
+// require.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
+// require.Greaterf(t, "b", "a", "error message %s", "formatted")
func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -656,7 +656,7 @@ func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...in
// HTTPBodyContains asserts that a specified handler returns a
// body that contains a string.
//
-// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
+// require.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
@@ -672,7 +672,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url s
// HTTPBodyContainsf asserts that a specified handler returns a
// body that contains a string.
//
-// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
+// require.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
@@ -688,7 +688,7 @@ func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url
// HTTPBodyNotContains asserts that a specified handler returns a
// body that does not contain a string.
//
-// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
+// require.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) {
@@ -704,7 +704,7 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, ur
// HTTPBodyNotContainsf asserts that a specified handler returns a
// body that does not contain a string.
//
-// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
+// require.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) {
@@ -719,7 +719,7 @@ func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, u
// HTTPError asserts that a specified handler returns an error status code.
//
-// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+// require.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
@@ -734,7 +734,7 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string,
// HTTPErrorf asserts that a specified handler returns an error status code.
//
-// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+// require.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
@@ -749,7 +749,7 @@ func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string,
// HTTPRedirect asserts that a specified handler returns a redirect status code.
//
-// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+// require.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
@@ -764,7 +764,7 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url strin
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
//
-// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
+// require.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
@@ -779,7 +779,7 @@ func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url stri
// HTTPStatusCode asserts that a specified handler returns a specified status code.
//
-// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
+// require.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501)
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) {
@@ -794,7 +794,7 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url str
// HTTPStatusCodef asserts that a specified handler returns a specified status code.
//
-// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
+// require.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) {
@@ -809,7 +809,7 @@ func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url st
// HTTPSuccess asserts that a specified handler returns a success status code.
//
-// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
+// require.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) {
@@ -824,7 +824,7 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string
// HTTPSuccessf asserts that a specified handler returns a success status code.
//
-// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
+// require.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) {
@@ -839,7 +839,7 @@ func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url strin
// Implements asserts that an object is implemented by the specified interface.
//
-// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
+// require.Implements(t, (*MyInterface)(nil), new(MyObject))
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -852,7 +852,7 @@ func Implements(t TestingT, interfaceObject interface{}, object interface{}, msg
// Implementsf asserts that an object is implemented by the specified interface.
//
-// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
+// require.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -865,7 +865,7 @@ func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, ms
// InDelta asserts that the two numerals are within delta of each other.
//
-// assert.InDelta(t, math.Pi, 22/7.0, 0.01)
+// require.InDelta(t, math.Pi, 22/7.0, 0.01)
func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -922,7 +922,7 @@ func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta f
// InDeltaf asserts that the two numerals are within delta of each other.
//
-// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
+// require.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -979,9 +979,9 @@ func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon fl
// IsDecreasing asserts that the collection is decreasing
//
-// assert.IsDecreasing(t, []int{2, 1, 0})
-// assert.IsDecreasing(t, []float{2, 1})
-// assert.IsDecreasing(t, []string{"b", "a"})
+// require.IsDecreasing(t, []int{2, 1, 0})
+// require.IsDecreasing(t, []float{2, 1})
+// require.IsDecreasing(t, []string{"b", "a"})
func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -994,9 +994,9 @@ func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
// IsDecreasingf asserts that the collection is decreasing
//
-// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
-// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
-// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
+// require.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
+// require.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
+// require.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1009,9 +1009,9 @@ func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface
// IsIncreasing asserts that the collection is increasing
//
-// assert.IsIncreasing(t, []int{1, 2, 3})
-// assert.IsIncreasing(t, []float{1, 2})
-// assert.IsIncreasing(t, []string{"a", "b"})
+// require.IsIncreasing(t, []int{1, 2, 3})
+// require.IsIncreasing(t, []float{1, 2})
+// require.IsIncreasing(t, []string{"a", "b"})
func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1024,9 +1024,9 @@ func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
// IsIncreasingf asserts that the collection is increasing
//
-// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
-// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
-// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
+// require.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
+// require.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
+// require.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1039,9 +1039,9 @@ func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface
// IsNonDecreasing asserts that the collection is not decreasing
//
-// assert.IsNonDecreasing(t, []int{1, 1, 2})
-// assert.IsNonDecreasing(t, []float{1, 2})
-// assert.IsNonDecreasing(t, []string{"a", "b"})
+// require.IsNonDecreasing(t, []int{1, 1, 2})
+// require.IsNonDecreasing(t, []float{1, 2})
+// require.IsNonDecreasing(t, []string{"a", "b"})
func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1054,9 +1054,9 @@ func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{})
// IsNonDecreasingf asserts that the collection is not decreasing
//
-// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
-// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
-// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
+// require.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
+// require.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
+// require.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1069,9 +1069,9 @@ func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interf
// IsNonIncreasing asserts that the collection is not increasing
//
-// assert.IsNonIncreasing(t, []int{2, 1, 1})
-// assert.IsNonIncreasing(t, []float{2, 1})
-// assert.IsNonIncreasing(t, []string{"b", "a"})
+// require.IsNonIncreasing(t, []int{2, 1, 1})
+// require.IsNonIncreasing(t, []float{2, 1})
+// require.IsNonIncreasing(t, []string{"b", "a"})
func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1084,9 +1084,9 @@ func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{})
// IsNonIncreasingf asserts that the collection is not increasing
//
-// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
-// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
-// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
+// require.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
+// require.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
+// require.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1121,7 +1121,7 @@ func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg strin
// JSONEq asserts that two JSON strings are equivalent.
//
-// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
+// require.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1134,7 +1134,7 @@ func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{
// JSONEqf asserts that two JSON strings are equivalent.
//
-// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
+// require.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1148,7 +1148,7 @@ func JSONEqf(t TestingT, expected string, actual string, msg string, args ...int
// Len asserts that the specified object has specific length.
// Len also fails if the object has a type that len() not accept.
//
-// assert.Len(t, mySlice, 3)
+// require.Len(t, mySlice, 3)
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1162,7 +1162,7 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
// Lenf asserts that the specified object has specific length.
// Lenf also fails if the object has a type that len() not accept.
//
-// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
+// require.Lenf(t, mySlice, 3, "error message %s", "formatted")
func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1175,9 +1175,9 @@ func Lenf(t TestingT, object interface{}, length int, msg string, args ...interf
// Less asserts that the first element is less than the second
//
-// assert.Less(t, 1, 2)
-// assert.Less(t, float64(1), float64(2))
-// assert.Less(t, "a", "b")
+// require.Less(t, 1, 2)
+// require.Less(t, float64(1), float64(2))
+// require.Less(t, "a", "b")
func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1190,10 +1190,10 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
// LessOrEqual asserts that the first element is less than or equal to the second
//
-// assert.LessOrEqual(t, 1, 2)
-// assert.LessOrEqual(t, 2, 2)
-// assert.LessOrEqual(t, "a", "b")
-// assert.LessOrEqual(t, "b", "b")
+// require.LessOrEqual(t, 1, 2)
+// require.LessOrEqual(t, 2, 2)
+// require.LessOrEqual(t, "a", "b")
+// require.LessOrEqual(t, "b", "b")
func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1206,10 +1206,10 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
// LessOrEqualf asserts that the first element is less than or equal to the second
//
-// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
-// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
-// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
-// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
+// require.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
+// require.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
+// require.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
+// require.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1222,9 +1222,9 @@ func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args .
// Lessf asserts that the first element is less than the second
//
-// assert.Lessf(t, 1, 2, "error message %s", "formatted")
-// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
-// assert.Lessf(t, "a", "b", "error message %s", "formatted")
+// require.Lessf(t, 1, 2, "error message %s", "formatted")
+// require.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
+// require.Lessf(t, "a", "b", "error message %s", "formatted")
func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1237,8 +1237,8 @@ func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...inter
// Negative asserts that the specified element is negative
//
-// assert.Negative(t, -1)
-// assert.Negative(t, -1.23)
+// require.Negative(t, -1)
+// require.Negative(t, -1.23)
func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1251,8 +1251,8 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) {
// Negativef asserts that the specified element is negative
//
-// assert.Negativef(t, -1, "error message %s", "formatted")
-// assert.Negativef(t, -1.23, "error message %s", "formatted")
+// require.Negativef(t, -1, "error message %s", "formatted")
+// require.Negativef(t, -1.23, "error message %s", "formatted")
func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1266,7 +1266,7 @@ func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) {
// Never asserts that the given condition doesn't satisfy in waitFor time,
// periodically checking the target function each tick.
//
-// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
+// require.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond)
func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1280,7 +1280,7 @@ func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.D
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
// periodically checking the target function each tick.
//
-// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
+// require.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1293,7 +1293,7 @@ func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.
// Nil asserts that the specified object is nil.
//
-// assert.Nil(t, err)
+// require.Nil(t, err)
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1306,7 +1306,7 @@ func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
// Nilf asserts that the specified object is nil.
//
-// assert.Nilf(t, err, "error message %s", "formatted")
+// require.Nilf(t, err, "error message %s", "formatted")
func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1344,8 +1344,8 @@ func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) {
// NoError asserts that a function returned no error (i.e. `nil`).
//
// actualObj, err := SomeFunction()
-// if assert.NoError(t, err) {
-// assert.Equal(t, expectedObj, actualObj)
+// if require.NoError(t, err) {
+// require.Equal(t, expectedObj, actualObj)
// }
func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -1360,8 +1360,8 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
// NoErrorf asserts that a function returned no error (i.e. `nil`).
//
// actualObj, err := SomeFunction()
-// if assert.NoErrorf(t, err, "error message %s", "formatted") {
-// assert.Equal(t, expectedObj, actualObj)
+// if require.NoErrorf(t, err, "error message %s", "formatted") {
+// require.Equal(t, expectedObj, actualObj)
// }
func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -1400,9 +1400,9 @@ func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) {
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
-// assert.NotContains(t, "Hello World", "Earth")
-// assert.NotContains(t, ["Hello", "World"], "Earth")
-// assert.NotContains(t, {"Hello": "World"}, "Earth")
+// require.NotContains(t, "Hello World", "Earth")
+// require.NotContains(t, ["Hello", "World"], "Earth")
+// require.NotContains(t, {"Hello": "World"}, "Earth")
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1416,9 +1416,9 @@ func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
-// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
-// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
-// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
+// require.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
+// require.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
+// require.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1429,11 +1429,51 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a
t.FailNow()
}
+// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// require.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false
+//
+// require.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true
+//
+// require.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true
+func NotElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if assert.NotElementsMatch(t, listA, listB, msgAndArgs...) {
+ return
+ }
+ t.FailNow()
+}
+
+// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// require.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
+//
+// require.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
+//
+// require.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
+func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if assert.NotElementsMatchf(t, listA, listB, msg, args...) {
+ return
+ }
+ t.FailNow()
+}
+
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
-// if assert.NotEmpty(t, obj) {
-// assert.Equal(t, "two", obj[1])
+// if require.NotEmpty(t, obj) {
+// require.Equal(t, "two", obj[1])
// }
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -1448,8 +1488,8 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
-// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
-// assert.Equal(t, "two", obj[1])
+// if require.NotEmptyf(t, obj, "error message %s", "formatted") {
+// require.Equal(t, "two", obj[1])
// }
func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -1463,7 +1503,7 @@ func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{})
// NotEqual asserts that the specified values are NOT equal.
//
-// assert.NotEqual(t, obj1, obj2)
+// require.NotEqual(t, obj1, obj2)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
@@ -1479,7 +1519,7 @@ func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs .
// NotEqualValues asserts that two objects are not equal even when converted to the same type
//
-// assert.NotEqualValues(t, obj1, obj2)
+// require.NotEqualValues(t, obj1, obj2)
func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1492,7 +1532,7 @@ func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAnd
// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
//
-// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
+// require.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1505,7 +1545,7 @@ func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg s
// NotEqualf asserts that the specified values are NOT equal.
//
-// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
+// require.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
@@ -1519,7 +1559,31 @@ func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string,
t.FailNow()
}
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
+// NotErrorAs asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if assert.NotErrorAs(t, err, target, msgAndArgs...) {
+ return
+ }
+ t.FailNow()
+}
+
+// NotErrorAsf asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) {
+ if h, ok := t.(tHelper); ok {
+ h.Helper()
+ }
+ if assert.NotErrorAsf(t, err, target, msg, args...) {
+ return
+ }
+ t.FailNow()
+}
+
+// NotErrorIs asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func NotErrorIs(t TestingT, err error, target error, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -1531,7 +1595,7 @@ func NotErrorIs(t TestingT, err error, target error, msgAndArgs ...interface{})
t.FailNow()
}
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
+// NotErrorIsf asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
@@ -1545,7 +1609,7 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf
// NotImplements asserts that an object does not implement the specified interface.
//
-// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
+// require.NotImplements(t, (*MyInterface)(nil), new(MyObject))
func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1558,7 +1622,7 @@ func NotImplements(t TestingT, interfaceObject interface{}, object interface{},
// NotImplementsf asserts that an object does not implement the specified interface.
//
-// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
+// require.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1571,7 +1635,7 @@ func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{},
// NotNil asserts that the specified object is not nil.
//
-// assert.NotNil(t, err)
+// require.NotNil(t, err)
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1584,7 +1648,7 @@ func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
// NotNilf asserts that the specified object is not nil.
//
-// assert.NotNilf(t, err, "error message %s", "formatted")
+// require.NotNilf(t, err, "error message %s", "formatted")
func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1597,7 +1661,7 @@ func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
//
-// assert.NotPanics(t, func(){ RemainCalm() })
+// require.NotPanics(t, func(){ RemainCalm() })
func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1610,7 +1674,7 @@ func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
//
-// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
+// require.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1623,8 +1687,8 @@ func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interfac
// NotRegexp asserts that a specified regexp does not match a string.
//
-// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
-// assert.NotRegexp(t, "^start", "it's not starting")
+// require.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
+// require.NotRegexp(t, "^start", "it's not starting")
func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1637,8 +1701,8 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf
// NotRegexpf asserts that a specified regexp does not match a string.
//
-// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
-// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
+// require.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
+// require.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1651,7 +1715,7 @@ func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ..
// NotSame asserts that two pointers do not reference the same object.
//
-// assert.NotSame(t, ptr1, ptr2)
+// require.NotSame(t, ptr1, ptr2)
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
@@ -1667,7 +1731,7 @@ func NotSame(t TestingT, expected interface{}, actual interface{}, msgAndArgs ..
// NotSamef asserts that two pointers do not reference the same object.
//
-// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
+// require.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
@@ -1685,8 +1749,8 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string,
// contain all elements given in the specified subset list(array, slice...) or
// map.
//
-// assert.NotSubset(t, [1, 3, 4], [1, 2])
-// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
+// require.NotSubset(t, [1, 3, 4], [1, 2])
+// require.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1701,8 +1765,8 @@ func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...i
// contain all elements given in the specified subset list(array, slice...) or
// map.
//
-// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
-// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
+// require.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
+// require.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1737,7 +1801,7 @@ func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
// Panics asserts that the code inside the specified PanicTestFunc panics.
//
-// assert.Panics(t, func(){ GoCrazy() })
+// require.Panics(t, func(){ GoCrazy() })
func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1752,7 +1816,7 @@ func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
// panics, and that the recovered panic value is an error that satisfies the
// EqualError comparison.
//
-// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
+// require.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1767,7 +1831,7 @@ func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAn
// panics, and that the recovered panic value is an error that satisfies the
// EqualError comparison.
//
-// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
+// require.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1781,7 +1845,7 @@ func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
-// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
+// require.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1795,7 +1859,7 @@ func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, m
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
-// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
+// require.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1808,7 +1872,7 @@ func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc,
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
//
-// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
+// require.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1821,8 +1885,8 @@ func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}
// Positive asserts that the specified element is positive
//
-// assert.Positive(t, 1)
-// assert.Positive(t, 1.23)
+// require.Positive(t, 1)
+// require.Positive(t, 1.23)
func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1835,8 +1899,8 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) {
// Positivef asserts that the specified element is positive
//
-// assert.Positivef(t, 1, "error message %s", "formatted")
-// assert.Positivef(t, 1.23, "error message %s", "formatted")
+// require.Positivef(t, 1, "error message %s", "formatted")
+// require.Positivef(t, 1.23, "error message %s", "formatted")
func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1849,8 +1913,8 @@ func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) {
// Regexp asserts that a specified regexp matches a string.
//
-// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
-// assert.Regexp(t, "start...$", "it's not starting")
+// require.Regexp(t, regexp.MustCompile("start"), "it's starting")
+// require.Regexp(t, "start...$", "it's not starting")
func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1863,8 +1927,8 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface
// Regexpf asserts that a specified regexp matches a string.
//
-// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
-// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
+// require.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
+// require.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1877,7 +1941,7 @@ func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...in
// Same asserts that two pointers reference the same object.
//
-// assert.Same(t, ptr1, ptr2)
+// require.Same(t, ptr1, ptr2)
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
@@ -1893,7 +1957,7 @@ func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...in
// Samef asserts that two pointers reference the same object.
//
-// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
+// require.Samef(t, ptr1, ptr2, "error message %s", "formatted")
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
@@ -1910,8 +1974,8 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg
// Subset asserts that the specified list(array, slice...) or map contains all
// elements given in the specified subset list(array, slice...) or map.
//
-// assert.Subset(t, [1, 2, 3], [1, 2])
-// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
+// require.Subset(t, [1, 2, 3], [1, 2])
+// require.Subset(t, {"x": 1, "y": 2}, {"x": 1})
func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1925,8 +1989,8 @@ func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...inte
// Subsetf asserts that the specified list(array, slice...) or map contains all
// elements given in the specified subset list(array, slice...) or map.
//
-// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
-// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
+// require.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
+// require.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1939,7 +2003,7 @@ func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args
// True asserts that the specified value is true.
//
-// assert.True(t, myBool)
+// require.True(t, myBool)
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1952,7 +2016,7 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) {
// Truef asserts that the specified value is true.
//
-// assert.Truef(t, myBool, "error message %s", "formatted")
+// require.Truef(t, myBool, "error message %s", "formatted")
func Truef(t TestingT, value bool, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1965,7 +2029,7 @@ func Truef(t TestingT, value bool, msg string, args ...interface{}) {
// WithinDuration asserts that the two times are within duration delta of each other.
//
-// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
+// require.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1978,7 +2042,7 @@ func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time
// WithinDurationf asserts that the two times are within duration delta of each other.
//
-// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
+// require.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -1991,7 +2055,7 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim
// WithinRange asserts that a time is within a time range (inclusive).
//
-// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
+// require.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
@@ -2004,7 +2068,7 @@ func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, m
// WithinRangef asserts that a time is within a time range (inclusive).
//
-// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
+// require.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl
index 55e42dde..8b328368 100644
--- a/vendor/github.com/stretchr/testify/require/require.go.tmpl
+++ b/vendor/github.com/stretchr/testify/require/require.go.tmpl
@@ -1,4 +1,4 @@
-{{.Comment}}
+{{ replace .Comment "assert." "require."}}
func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
if h, ok := t.(tHelper); ok { h.Helper() }
if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return }
diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go
index eee8310a..1bd87304 100644
--- a/vendor/github.com/stretchr/testify/require/require_forward.go
+++ b/vendor/github.com/stretchr/testify/require/require_forward.go
@@ -187,8 +187,8 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
EqualExportedValuesf(a.t, expected, actual, msg, args...)
}
-// EqualValues asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValues asserts that two objects are equal or convertible to the larger
+// type and equal.
//
// a.EqualValues(uint32(123), int32(123))
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
@@ -198,8 +198,8 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
EqualValues(a.t, expected, actual, msgAndArgs...)
}
-// EqualValuesf asserts that two objects are equal or convertible to the same types
-// and equal.
+// EqualValuesf asserts that two objects are equal or convertible to the larger
+// type and equal.
//
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
@@ -337,7 +337,7 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
// a.EventuallyWithT(func(c *assert.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -362,7 +362,7 @@ func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), w
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
-// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
+// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
if h, ok := a.t.(tHelper); ok {
h.Helper()
@@ -1129,6 +1129,40 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin
NotContainsf(a.t, s, contains, msg, args...)
}
+// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// a.NotElementsMatch([1, 1, 2, 3], [1, 1, 2, 3]) -> false
+//
+// a.NotElementsMatch([1, 1, 2, 3], [1, 2, 3]) -> true
+//
+// a.NotElementsMatch([1, 2, 3], [1, 2, 4]) -> true
+func (a *Assertions) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ NotElementsMatch(a.t, listA, listB, msgAndArgs...)
+}
+
+// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
+// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
+// the number of appearances of each of them in both lists should not match.
+// This is an inverse of ElementsMatch.
+//
+// a.NotElementsMatchf([1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
+//
+// a.NotElementsMatchf([1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
+//
+// a.NotElementsMatchf([1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
+func (a *Assertions) NotElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ NotElementsMatchf(a.t, listA, listB, msg, args...)
+}
+
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
// a slice or a channel with len == 0.
//
@@ -1201,7 +1235,25 @@ func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg str
NotEqualf(a.t, expected, actual, msg, args...)
}
-// NotErrorIs asserts that at none of the errors in err's chain matches target.
+// NotErrorAs asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ NotErrorAs(a.t, err, target, msgAndArgs...)
+}
+
+// NotErrorAsf asserts that none of the errors in err's chain matches target,
+// but if so, sets target to that error value.
+func (a *Assertions) NotErrorAsf(err error, target interface{}, msg string, args ...interface{}) {
+ if h, ok := a.t.(tHelper); ok {
+ h.Helper()
+ }
+ NotErrorAsf(a.t, err, target, msg, args...)
+}
+
+// NotErrorIs asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) {
if h, ok := a.t.(tHelper); ok {
@@ -1210,7 +1262,7 @@ func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface
NotErrorIs(a.t, err, target, msgAndArgs...)
}
-// NotErrorIsf asserts that at none of the errors in err's chain matches target.
+// NotErrorIsf asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) {
if h, ok := a.t.(tHelper); ok {
diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go
index 91772dfe..6b7ce929 100644
--- a/vendor/github.com/stretchr/testify/require/requirements.go
+++ b/vendor/github.com/stretchr/testify/require/requirements.go
@@ -6,7 +6,7 @@ type TestingT interface {
FailNow()
}
-type tHelper interface {
+type tHelper = interface {
Helper()
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index b6ab6e3a..e69d2672 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -119,6 +119,13 @@ github.com/crazy-max/gonfig/types
# github.com/davecgh/go-spew v1.1.1
## explicit
github.com/davecgh/go-spew/spew
+# github.com/dromara/carbon/v2 v2.5.2
+## explicit; go 1.17
+github.com/dromara/carbon/v2
+github.com/dromara/carbon/v2/calendar
+github.com/dromara/carbon/v2/calendar/julian
+github.com/dromara/carbon/v2/calendar/lunar
+github.com/dromara/carbon/v2/calendar/persian
# github.com/gabriel-vasile/mimetype v1.4.3
## explicit; go 1.20
github.com/gabriel-vasile/mimetype
@@ -135,13 +142,6 @@ github.com/go-playground/universal-translator
# github.com/go-playground/validator/v10 v10.23.0
## explicit; go 1.18
github.com/go-playground/validator/v10
-# github.com/golang-module/carbon/v2 v2.3.10
-## explicit; go 1.16
-github.com/golang-module/carbon/v2
-github.com/golang-module/carbon/v2/calendar
-github.com/golang-module/carbon/v2/calendar/julian
-github.com/golang-module/carbon/v2/calendar/lunar
-github.com/golang-module/carbon/v2/calendar/persian
# github.com/hashicorp/go-cleanhttp v0.5.2
## explicit; go 1.13
github.com/hashicorp/go-cleanhttp
@@ -176,9 +176,10 @@ github.com/rs/zerolog
github.com/rs/zerolog/internal/cbor
github.com/rs/zerolog/internal/json
github.com/rs/zerolog/log
-# github.com/stretchr/testify v1.9.0
+# github.com/stretchr/testify v1.10.0
## explicit; go 1.17
github.com/stretchr/testify/assert
+github.com/stretchr/testify/assert/yaml
github.com/stretchr/testify/require
# golang.org/x/crypto v0.31.0
## explicit; go 1.20