diff --git a/go.mod b/go.mod index 05991166..a08cfa55 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/docker/docker v28.5.2+incompatible github.com/docker/go-connections v0.6.0 github.com/docker/go-units v0.5.0 - github.com/dromara/carbon/v2 v2.6.14 + github.com/dromara/carbon/v2 v2.6.15 github.com/eclipse/paho.mqtt.golang v1.5.1 github.com/go-gomail/gomail v0.0.0-20160411212932-81ebce5c23df github.com/go-playground/validator/v10 v10.28.0 diff --git a/go.sum b/go.sum index 6e706984..17fc1867 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQ github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dromara/carbon/v2 v2.6.14 h1:U4mN6eH/E5GqPI67MSro8aJ5yg1DbenKItKTFwr5Fqg= -github.com/dromara/carbon/v2 v2.6.14/go.mod h1:NGo3reeV5vhWCYWcSqbJRZm46MEwyfYI5EJRdVFoLJo= +github.com/dromara/carbon/v2 v2.6.15 h1:3HuC3XcWczIHUTbg/f0CSVydtKEdM+P0GM1sdsbwXmI= +github.com/dromara/carbon/v2 v2.6.15/go.mod h1:NGo3reeV5vhWCYWcSqbJRZm46MEwyfYI5EJRdVFoLJo= github.com/eclipse/paho.mqtt.golang v1.5.1 h1:/VSOv3oDLlpqR2Epjn1Q7b2bSTplJIeV2ISgCl2W7nE= github.com/eclipse/paho.mqtt.golang v1.5.1/go.mod h1:1/yJCneuyOoCOzKSsOTUc0AJfpsItBGWvYpBLimhArU= github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU= diff --git a/vendor/github.com/dromara/carbon/v2/README.cn.md b/vendor/github.com/dromara/carbon/v2/README.cn.md index 112b9fe9..8e354907 100644 --- a/vendor/github.com/dromara/carbon/v2/README.cn.md +++ b/vendor/github.com/dromara/carbon/v2/README.cn.md @@ -13,11 +13,12 @@ ## 项目简介 -`Carbon` 是一个轻量级、语义化、对开发者友好的 `golang` 时间处理库,不依赖于 `任何` 第三方库, `100%` 单元测试覆盖率,已被 [awesome-go](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") 和 [hello-github](https://hellogithub.com/repository/dromara/carbon "hello-github") 收录,并获得 +`Carbon` 是一个轻量级、语义化、对开发者友好的 `golang` 时间处理库,不依赖于 `任何` 第三方库, `100%` 单元测试覆盖率,已被 [docker](https://github.com/docker/docker-language-server/blob/main/go.mod#L10 "docker") 组织使用以及被 [awesome-go](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") 和 [hello-github](https://hellogithub.com/repository/dromara/carbon "hello-github") 收录,并获得 `gitee` 2024 年最有价值项目(`GVP`)和 `gitcode` 2024 年度开源摘星计划 (`G-Star`) 项目 -gvp -g-star +docker +gvp +g-star ## 仓库地址 @@ -31,7 +32,7 @@ ### 安装使用 -> go version >= 1.18 +> go version >= 1.19 ```go // 使用 github 库 @@ -102,9 +103,12 @@ carbon.IsTestNow() // false -[如何为 carbon 添加新的本地化语言支持](docs/CONTRIBUTING.cn.md) -## 赞助 +## 翻译者 +欢迎帮助将 `Carbon` 翻译为更多本地化语言 +[如何为 carbon 添加新的本地化语言支持](https://carbon.go-pkg.com/zh/appendix/contribution-guide.html) + +## 赞助 `Carbon` 是一个非商业开源项目, 如果你想支持 `Carbon`, 你可以为开发者 [购买一杯咖啡](https://carbon.go-pkg.com/zh/sponsor.html) diff --git a/vendor/github.com/dromara/carbon/v2/README.ja.md b/vendor/github.com/dromara/carbon/v2/README.ja.md index f5846618..6a5a73e0 100644 --- a/vendor/github.com/dromara/carbon/v2/README.ja.md +++ b/vendor/github.com/dromara/carbon/v2/README.ja.md @@ -13,7 +13,9 @@ ## イントロ -`Carbon` は軽量、セマンティック、開発者に優しい `golang` 時間処理ライブラリ, `いかなる`第三者ライブラリにも依存せず、`100%`ユニットテストカバレッジ率は、[awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go") と [hello-github](https://hellogithub.com/en/repository/dromara/carbon "hello-github") 収録 +`Carbon` は軽量でセマンティックで開発者に優しい `golang` 時間処理ライブラリで、サードパーティ製ライブラリに依存せず、ユニットテストのカバー率は `100%` で、[docker](https://github.com/docker/docker-language-server/blob/main/go.mod#L10 "docker") に公式採用され、[awesome-go](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") と [hello-github](https://hellogithub.com/repository/dromara/carbon "hello-github") にも収録されています。 + +docker ## リポジトリ @@ -26,7 +28,7 @@ ## クイックスタート ### インストール -> go version >= 1.18 +> go version >= 1.19 ```go // github から使う @@ -39,13 +41,13 @@ import "gitee.com/dromara/carbon/v2" // gitcode から使う go get -u gitcode.com/dromara/carbon/v2 -import "gitcode.com/dromara/carbon/v2" +import "gitcode.com/dromara/gitcode/v2" ``` `Carbon` は [dromara](https://dromara.org/ "dromara") 組織に寄付されたためリポジトリのURLが変更されました。以前のリポジトリ `golang-module/carbon` を使用している場合は`go.mod`で新しいリポジトリURLに変更するか下記コマンドを実行します ```go -go mod edit -replace github.com/golang-module/carbon/v2=github.com/dromara/carbon/v2 +go mod edit -replace github.com/golang-module/carbon/v2 = github.com/dromara/carbon/v2 ``` ### 使い方と例 @@ -71,14 +73,14 @@ carbon.CreateFromDateTime(2020, 8, 5, 13, 14, 15).ToString() // 2020-08-05 13:14 carbon.CreateFromTimestamp(1596633255).ToString() // 2020-08-05 13:14:15 +0000 UTC carbon.Parse("2020-07-05 13:14:15").DiffForHumans() // 1 month before -carbon.Parse("2020-07-05 13:14:15").SetLocale("jp").DiffForHumans() // 1 ヶ月前 +carbon.Parse("2020-07-05 13:14:15").SetLocale("zh-CN").DiffForHumans() // 1 月前 carbon.ClearTestNow() carbon.IsTestNow() // false ``` -詳細については 公式ドキュメント +より多くの使用例については、公式ドキュメントをご覧ください。 -より多くの使用例については、公式ドキュメントをご覧ください。性能テストレポートについては、[分析レポート](docs/BENCHMARK.ja.md)をご参照ください +性能テストレポートについては、[ベンチマークレポート](docs/BENCHMARK.ja.md)をご参照ください ## リファレンス @@ -96,7 +98,10 @@ carbon.IsTestNow() // false -[Carbon に新しいローカライズ言語サポートを追加する方法](docs/CONTRIBUTING.ja.md) +## 翻訳者 +`Carbon` を他のローカライズ言語に翻訳してくださる方を募集しています + +[Carbon に新しいローカライズ言語サポートを追加する方法](https://carbon.go-pkg.com/ja/appendix/contribution-guide.html) ## スポンサー diff --git a/vendor/github.com/dromara/carbon/v2/README.ko.md b/vendor/github.com/dromara/carbon/v2/README.ko.md index e6090b42..4a9c2c33 100644 --- a/vendor/github.com/dromara/carbon/v2/README.ko.md +++ b/vendor/github.com/dromara/carbon/v2/README.ko.md @@ -9,11 +9,13 @@ [![HelloGitHub](https://api.hellogithub.com/v1/widgets/recommend.svg?rid=0eddd8c3469549b7b246f85a83d1c42e&claim_uid=kKBvMpyxSgLhmJO&theme=small)](https://hellogithub.com/en/repository/dromara/carbon) [![License](https://img.shields.io/github/license/dromara/carbon)](https://github.com/dromara/carbon/blob/master/LICENSE) -한국어 | [English](README.md) | [简体中文](README.zh.md) | [日本語](README.ja.md) +한국어 | [English](README.md) | [简体中文](README.cn.md) | [日本語](README.ja.md) ## 소개 -`Carbon`은 `golang`을 위한 간단하고, 의미론적이며, 개발자 친화적인 시간 패키지입니다. `100%` 단위 테스트 커버리지를 제공하며, `어떤` 서드파티 패키지에도 의존하지 않으며, [awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go")와 [hello-github](https://hellogithub.com/en/repository/dromara/carbon "hello-github")에 포함되어 있습니다. +`Carbon` 은 가벼우면서도 의미론적이고 개발자 친화적인 `golang` 시간 처리 라이브러리로, `어떤` 서드파티 라이브러리에도 의존하지 않으며, `100%` 단위 테스트 커버리지를 가지고 있으며, [docker](https://github.com/docker/docker-language-server/blob/main/go.mod#L10 "docker")에 공식적으로 사용되고 있고 [awesome-go](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") 와 [hello-github](https://hellogithub.com/repository/dromara/carbon "hello-github")에도 수록되어 있습니다. + +docker ## 저장소 @@ -26,7 +28,7 @@ ## 빠른 시작 ### 설치 -> go version >= 1.18 +> go version >= 1.19 ```go // GitHub를 통해 @@ -39,7 +41,7 @@ import "gitee.com/dromara/carbon/v2" // GitCode를 통해 go get -u gitcode.com/dromara/carbon/v2 -import "gitee.com/dromara/gitcode/v2" +import "gitcode.com/dromara/gitcode/v2" ``` `Carbon`은 [dromara](https://dromara.org/ "dromara") 조직에 기부되었으며, 저장소 URL이 변경되었습니다. 이전에 사용하던 저장소가 `golang-module/carbon`이었다면, `go.mod`에서 원래 저장소를 새 저장소로 교체하거나 다음 명령을 실행하세요: @@ -77,7 +79,9 @@ carbon.ClearTestNow() carbon.IsTestNow() // false ``` -더 많은 사용 예시는 공식 문서를 참조하세요. 성능 테스트 보고서는 [분석 보고서](docs/BENCHMARK.ko.md)를 참조하세요. +더 많은 사용 예시는 공식 문서를 참조하세요. + +성능 테스트 보고서는 [벤치마크 보고서](docs/BENCHMARK.ko.md)를 참조하세요. ## 참고 자료 @@ -95,7 +99,10 @@ carbon.IsTestNow() // false -[Carbon에 새로운 로컬라이즈드 언어 지원을 추가하는 방법](docs/CONTRIBUTING.ko.md) +## 번역자 +`Carbon` 을 더 많은 로컬라이즈드 언어로 번역하는 데 도움을 요청드립니다 + +[Carbon에 새로운 로컬라이즈드 언어 지원을 추가하는 방법](https://carbon.go-pkg.com/ko/appendix/contribution-guide.html) ## 스폰서 diff --git a/vendor/github.com/dromara/carbon/v2/README.md b/vendor/github.com/dromara/carbon/v2/README.md index 1f76c37b..8f5ecb04 100644 --- a/vendor/github.com/dromara/carbon/v2/README.md +++ b/vendor/github.com/dromara/carbon/v2/README.md @@ -13,7 +13,9 @@ English | [简体中文](README.cn.md) | [日本語](README.ja.md) | [한국어] ## Introduction -`Carbon` is a simple, semantic and developer-friendly time package for `golang`, `100%` unit test coverage, doesn't depend on `any` third-party package and has been included by [awesome-go](https://github.com/avelino/awesome-go#date-and-time "awesome-go") and [hello-github](https://hellogithub.com/en/repository/dromara/carbon "hello-github") +`Carbon` is a lightweight, semantic, and developer-friendly `golang` time package that doesn't depend on `any` third-party package, has `100%` unit test coverage, and has been used by [docker](https://github.com/docker/docker-language-server/blob/main/go.mod#L10 "docker") organization as well as included by [awesome-go](https://github.com/yinggaozhen/awesome-go-cn#日期和时间 "awesome-go-cn") and [hello-github](https://hellogithub.com/repository/dromara/carbon "hello-github"). + +docker ## Repository @@ -26,20 +28,20 @@ English | [简体中文](README.cn.md) | [日本語](README.ja.md) | [한국어] ## Quick Start ### Installation -> go version >= 1.18 +> go version >= 1.19 ```go -// By github +// Via github go get -u github.com/dromara/carbon/v2 import "github.com/dromara/carbon/v2" -// By gitee +// Via gitee go get -u gitee.com/dromara/carbon/v2 import "gitee.com/dromara/carbon/v2" -// By gitcode +// Via gitcode go get -u gitcode.com/dromara/carbon/v2 -import "gitee.com/dromara/gitcode/v2" +import "gitcode.com/dromara/gitcode/v2" ``` `Carbon` was donated to the [dromara](https://dromara.org/ "dromara") organization, the repository URL has changed. If @@ -100,7 +102,10 @@ Thanks to all the following who contributed to `Carbon`: -[How to add new localized language support to carbon](docs/CONTRIBUTING.en.md) +## Translators +Ask for help to translate `Carbon` in other localized languages + +[How to add new localized language support to carbon](https://carbon.go-pkg.com/appendix/contribution-guide.html) ## Sponsors diff --git a/vendor/github.com/dromara/carbon/v2/constants.go b/vendor/github.com/dromara/carbon/v2/constants.go index 11092784..aa5b9df7 100644 --- a/vendor/github.com/dromara/carbon/v2/constants.go +++ b/vendor/github.com/dromara/carbon/v2/constants.go @@ -5,7 +5,7 @@ import ( ) // Version current version -const Version = "2.6.14" +const Version = "2.6.15" // timezone constants const ( @@ -180,6 +180,7 @@ const ( RubyDateLayout = time.RubyDate UnixDateLayout = time.UnixDate W3cLayout = RFC3339Layout + HttpLayout = "Mon, 02 Jan 2006 15:04:05 GMT" RFC1036Layout = "Mon, 02 Jan 06 15:04:05 -0700" RFC1123Layout = time.RFC1123 @@ -250,6 +251,8 @@ const ( RssFormat = "D, d M Y H:i:s O" RubyDateFormat = "D M d H:i:s O Y" UnixDateFormat = "D M j H:i:s Z Y" + W3cFormat = RFC3339Format + HttpFormat = "D, d M Y H:i:s \\G\\M\\T" RFC1036Format = "D, d M y H:i:s O" RFC1123Format = "D, d M Y H:i:s Z" diff --git a/vendor/github.com/dromara/carbon/v2/creator.go b/vendor/github.com/dromara/carbon/v2/creator.go index 580b130d..b5663370 100644 --- a/vendor/github.com/dromara/carbon/v2/creator.go +++ b/vendor/github.com/dromara/carbon/v2/creator.go @@ -13,7 +13,7 @@ func CreateFromStdTime(stdTime StdTime, timezone ...string) *Carbon { loc *Location err error ) - if loc, err = parseTimezone(timezone[0]); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } return NewCarbon(stdTime.In(loc)) @@ -22,16 +22,10 @@ func CreateFromStdTime(stdTime StdTime, timezone ...string) *Carbon { // CreateFromTimestamp creates a Carbon instance from a given timestamp with second precision. func CreateFromTimestamp(timestamp int64, timezone ...string) *Carbon { var ( - tz string loc *Location err error ) - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - if loc, err = parseTimezone(tz); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } return NewCarbon(time.Unix(timestamp, MinNanosecond).In(loc)) @@ -40,16 +34,10 @@ func CreateFromTimestamp(timestamp int64, timezone ...string) *Carbon { // CreateFromTimestampMilli creates a Carbon instance from a given timestamp with millisecond precision. func CreateFromTimestampMilli(timestampMilli int64, timezone ...string) *Carbon { var ( - tz string loc *Location err error ) - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - if loc, err = parseTimezone(tz); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } return NewCarbon(time.Unix(timestampMilli/1e3, (timestampMilli%1e3)*1e6).In(loc)) @@ -58,16 +46,10 @@ func CreateFromTimestampMilli(timestampMilli int64, timezone ...string) *Carbon // CreateFromTimestampMicro creates a Carbon instance from a given timestamp with microsecond precision. func CreateFromTimestampMicro(timestampMicro int64, timezone ...string) *Carbon { var ( - tz string loc *Location err error ) - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - if loc, err = parseTimezone(tz); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } return NewCarbon(time.Unix(timestampMicro/1e6, (timestampMicro%1e6)*1e3).In(loc)) @@ -76,16 +58,10 @@ func CreateFromTimestampMicro(timestampMicro int64, timezone ...string) *Carbon // CreateFromTimestampNano creates a Carbon instance from a given timestamp with nanosecond precision. func CreateFromTimestampNano(timestampNano int64, timezone ...string) *Carbon { var ( - tz string loc *Location err error ) - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - if loc, err = parseTimezone(tz); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } return NewCarbon(time.Unix(timestampNano/1e9, timestampNano%1e9).In(loc)) @@ -158,16 +134,10 @@ func CreateFromTimeNano(hour, minute, second, nanosecond int, timezone ...string // creates a new Carbon instance from a given date, time and nanosecond. func create(year, month, day, hour, minute, second, nanosecond int, timezone ...string) *Carbon { var ( - tz string loc *Location err error ) - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - if loc, err = parseTimezone(tz); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } return NewCarbon(time.Date(year, time.Month(month), day, hour, minute, second, nanosecond, loc)) diff --git a/vendor/github.com/dromara/carbon/v2/difference.go b/vendor/github.com/dromara/carbon/v2/difference.go index 1fa64693..2cc960fa 100644 --- a/vendor/github.com/dromara/carbon/v2/difference.go +++ b/vendor/github.com/dromara/carbon/v2/difference.go @@ -235,7 +235,15 @@ func (c *Carbon) DiffInDuration(carbon ...*Carbon) Duration { // DiffAbsInDuration gets the difference in duration with absolute value. func (c *Carbon) DiffAbsInDuration(carbon ...*Carbon) Duration { - return c.DiffInDuration(carbon...).Abs() + d := c.DiffInDuration(carbon...) + switch { + case d >= 0: + return d + case d == minDuration: + return maxDuration + default: + return -d + } } // DiffForHumans gets the difference in a human-readable format, i18n is supported. diff --git a/vendor/github.com/dromara/carbon/v2/helper.go b/vendor/github.com/dromara/carbon/v2/helper.go index 16a00e20..94c4b427 100644 --- a/vendor/github.com/dromara/carbon/v2/helper.go +++ b/vendor/github.com/dromara/carbon/v2/helper.go @@ -131,24 +131,30 @@ func format2layout(format string) string { // timezoneCache caches parsed timezone locations to avoid repeated parsing var timezoneCache sync.Map -// parses a timezone string as a time.Location instance. -func parseTimezone(timezone string) (loc *Location, err error) { - if timezone == "" { +// parses timezone strings as a time.Location instance. +func parseTimezone(timezone ...string) (loc *Location, err error) { + var tz string + if len(timezone) > 0 { + tz = timezone[0] + } else { + tz = DefaultTimezone + } + if tz == "" { return nil, ErrEmptyTimezone() } // Check cache first - if cached, exists := timezoneCache.Load(timezone); exists { + if cached, exists := timezoneCache.Load(tz); exists { return cached.(*Location), nil } - if loc, err = time.LoadLocation(timezone); err != nil { - err = fmt.Errorf("%w: %w", ErrInvalidTimezone(timezone), err) + if loc, err = time.LoadLocation(tz); err != nil { + err = fmt.Errorf("%w: %w", ErrInvalidTimezone(tz), err) return } // Cache the successful result - timezoneCache.Store(timezone, loc) + timezoneCache.Store(tz, loc) return } diff --git a/vendor/github.com/dromara/carbon/v2/lang/af.json b/vendor/github.com/dromara/carbon/v2/lang/af.json new file mode 100644 index 00000000..618e54e0 --- /dev/null +++ b/vendor/github.com/dromara/carbon/v2/lang/af.json @@ -0,0 +1,22 @@ +{ + "name": "Afrikaans", + "author": "https://cursor.com/", + "months": "Januarie|Februarie|Maart|April|Mei|Junie|Julie|Augustus|September|Oktober|November|Desember", + "short_months": "Jan|Feb|Mrt|Apr|Mei|Jun|Jul|Aug|Sep|Okt|Nov|Des", + "weeks": "Sondag|Maandag|Dinsdag|Woensdag|Donderdag|Vrydag|Saterdag", + "short_weeks": "So|Ma|Di|Wo|Do|Vr|Sa", + "seasons": "Lente|Somer|Herfs|Winter", + "constellations": "Ram|Bul|Tweelinge|Kreef|Leeu|Maagd|Weegskaal|Skerpioen|Boogskutter|Steenbok|Waterdraer|Visse", + "year": "1 jaar|%d jare", + "month": "1 maand|%d maande", + "week": "1 week|%d weke", + "day": "1 dag|%d dae", + "hour": "1 uur|%d ure", + "minute": "1 minuut|%d minute", + "second": "1 sekonde|%d sekondes", + "now": "nou net", + "ago": "%s gelede", + "from_now": "%s van nou af", + "before": "%s voor", + "after": "%s na" +} diff --git a/vendor/github.com/dromara/carbon/v2/lang/mn.json b/vendor/github.com/dromara/carbon/v2/lang/mn.json new file mode 100644 index 00000000..88022af3 --- /dev/null +++ b/vendor/github.com/dromara/carbon/v2/lang/mn.json @@ -0,0 +1,22 @@ +{ + "name": "Mongolian", + "author": "https://cursor.com/", + "months": "Нэгдүгээр сар|Хоёрдугаар сар|Гуравдугаар сар|Дөрөвдүгээр сар|Тавдугаар сар|Зургадугаар сар|Долдугаар сар|Наймдугаар сар|Есдүгээр сар|Аравдугаар сар|Арван нэгдүгээр сар|Арван хоёрдугаар сар", + "short_months": "1-р сар|2-р сар|3-р сар|4-р сар|5-р сар|6-р сар|7-р сар|8-р сар|9-р сар|10-р сар|11-р сар|12-р сар", + "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 дараа" +} diff --git a/vendor/github.com/dromara/carbon/v2/lang/nb.json b/vendor/github.com/dromara/carbon/v2/lang/nb.json index 0da803b8..9ec0ea5b 100644 --- a/vendor/github.com/dromara/carbon/v2/lang/nb.json +++ b/vendor/github.com/dromara/carbon/v2/lang/nb.json @@ -1,5 +1,5 @@ { - "name": "Norsk bokmål", + "name": "Norwegian", "author": "https://github.com/bendikrb ", "months": "januar|februar|mars|april|mai|juni|juli|august|september|oktober|november|desember", "short_months": "jan|feb|mar|apr|mai|jun|jul|aug|sep|okt|nov|des", diff --git a/vendor/github.com/dromara/carbon/v2/lang/nl.json b/vendor/github.com/dromara/carbon/v2/lang/nl.json index e9df4408..bde46306 100644 --- a/vendor/github.com/dromara/carbon/v2/lang/nl.json +++ b/vendor/github.com/dromara/carbon/v2/lang/nl.json @@ -3,7 +3,7 @@ "author": "https://github.com/RemcoE33", "months": "januari|februari|maart|april|mei|juni|juli|augustus|september|oktober|november|december", "short_months": "jan|feb|mrt|apr|mei|jun|jul|aug|sep|okt|nov|dec", - "weeks": "Zondag|Maandag|Dinsdag|Woensdag|Donderdag|Vrijdag|Zaterdag|Zondag", + "weeks": "Zondag|Maandag|Dinsdag|Woensdag|Donderdag|Vrijdag|Zaterdag", "short_weeks": "zo|ma|di|wo|do|vr|za", "seasons": "Lente|Zomer|Herfst|Winter", "constellations": "Ram|Stier|Tweelingen|Kreeft|Leeuw|Maagd|Weegschaal|Schorpioen|Boogschutter|Steenbok|Waterman|Vissen", diff --git a/vendor/github.com/dromara/carbon/v2/outputer.go b/vendor/github.com/dromara/carbon/v2/outputer.go index 4fa252f0..a09dfd67 100644 --- a/vendor/github.com/dromara/carbon/v2/outputer.go +++ b/vendor/github.com/dromara/carbon/v2/outputer.go @@ -18,7 +18,7 @@ func (c *Carbon) GoString() string { // ToString outputs a string in "2006-01-02 15:04:05.999999999 -0700 MST" layout. func (c *Carbon) ToString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -29,7 +29,7 @@ func (c *Carbon) ToString(timezone ...string) string { // ToMonthString outputs a string in month layout like "January", i18n is supported. func (c *Carbon) ToMonthString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -55,7 +55,7 @@ func (c *Carbon) ToMonthString(timezone ...string) string { // ToShortMonthString outputs a string in short month layout like "Jan", i18n is supported. func (c *Carbon) ToShortMonthString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -81,7 +81,7 @@ func (c *Carbon) ToShortMonthString(timezone ...string) string { // ToWeekString outputs a string in week layout like "Sunday", i18n is supported. func (c *Carbon) ToWeekString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -107,7 +107,7 @@ func (c *Carbon) ToWeekString(timezone ...string) string { // ToShortWeekString outputs a string in short week layout like "Sun", i18n is supported. func (c *Carbon) ToShortWeekString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -133,7 +133,7 @@ func (c *Carbon) ToShortWeekString(timezone ...string) string { // ToDayDateTimeString outputs a string in "Mon, Jan 2, 2006 3:04 PM" layout. func (c *Carbon) ToDayDateTimeString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -144,7 +144,7 @@ func (c *Carbon) ToDayDateTimeString(timezone ...string) string { // ToDateTimeString outputs a string in "2006-01-02 15:04:05" layout. func (c *Carbon) ToDateTimeString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -155,7 +155,7 @@ func (c *Carbon) ToDateTimeString(timezone ...string) string { // ToDateTimeMilliString outputs a string in "2006-01-02 15:04:05.999" layout. func (c *Carbon) ToDateTimeMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -166,7 +166,7 @@ func (c *Carbon) ToDateTimeMilliString(timezone ...string) string { // ToDateTimeMicroString outputs a string in "2006-01-02 15:04:05.999999" layout. func (c *Carbon) ToDateTimeMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -177,7 +177,7 @@ func (c *Carbon) ToDateTimeMicroString(timezone ...string) string { // ToDateTimeNanoString outputs a string in "2006-01-02 15:04:05.999999999" layout. func (c *Carbon) ToDateTimeNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -188,7 +188,7 @@ func (c *Carbon) ToDateTimeNanoString(timezone ...string) string { // ToShortDateTimeString outputs a string in "20060102150405" layout. func (c *Carbon) ToShortDateTimeString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -200,7 +200,7 @@ func (c *Carbon) ToShortDateTimeString(timezone ...string) string { // 输出 "20060102150405.999" 格式字符串 func (c *Carbon) ToShortDateTimeMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -211,7 +211,7 @@ func (c *Carbon) ToShortDateTimeMilliString(timezone ...string) string { // ToShortDateTimeMicroString outputs a string in "20060102150405.999999" layout. func (c *Carbon) ToShortDateTimeMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -222,7 +222,7 @@ func (c *Carbon) ToShortDateTimeMicroString(timezone ...string) string { // ToShortDateTimeNanoString outputs a string in "20060102150405.999999999" layout. func (c *Carbon) ToShortDateTimeNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -233,7 +233,7 @@ func (c *Carbon) ToShortDateTimeNanoString(timezone ...string) string { // ToDateString outputs a string in "2006-01-02" layout. func (c *Carbon) ToDateString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -244,7 +244,7 @@ func (c *Carbon) ToDateString(timezone ...string) string { // ToDateMilliString outputs a string in "2006-01-02.999" layout. func (c *Carbon) ToDateMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -255,7 +255,7 @@ func (c *Carbon) ToDateMilliString(timezone ...string) string { // ToDateMicroString outputs a string in "2006-01-02.999999" layout. func (c *Carbon) ToDateMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -266,7 +266,7 @@ func (c *Carbon) ToDateMicroString(timezone ...string) string { // ToDateNanoString outputs a string in "2006-01-02.999999999" layout. func (c *Carbon) ToDateNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -277,7 +277,7 @@ func (c *Carbon) ToDateNanoString(timezone ...string) string { // ToShortDateString outputs a string in "20060102" layout. func (c *Carbon) ToShortDateString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -288,7 +288,7 @@ func (c *Carbon) ToShortDateString(timezone ...string) string { // ToShortDateMilliString outputs a string in "20060102.999" layout. func (c *Carbon) ToShortDateMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -299,7 +299,7 @@ func (c *Carbon) ToShortDateMilliString(timezone ...string) string { // ToShortDateMicroString outputs a string in "20060102.999999" layout. func (c *Carbon) ToShortDateMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -310,7 +310,7 @@ func (c *Carbon) ToShortDateMicroString(timezone ...string) string { // ToShortDateNanoString outputs a string in "20060102.999999999" layout. func (c *Carbon) ToShortDateNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -321,7 +321,7 @@ func (c *Carbon) ToShortDateNanoString(timezone ...string) string { // ToTimeString outputs a string in "15:04:05" layout. func (c *Carbon) ToTimeString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -332,7 +332,7 @@ func (c *Carbon) ToTimeString(timezone ...string) string { // ToTimeMilliString outputs a string in "15:04:05.999" layout. func (c *Carbon) ToTimeMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -343,7 +343,7 @@ func (c *Carbon) ToTimeMilliString(timezone ...string) string { // ToTimeMicroString outputs a string in "15:04:05.999999" layout. func (c *Carbon) ToTimeMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -354,7 +354,7 @@ func (c *Carbon) ToTimeMicroString(timezone ...string) string { // ToTimeNanoString outputs a string in "15:04:05.999999999" layout. func (c *Carbon) ToTimeNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -365,7 +365,7 @@ func (c *Carbon) ToTimeNanoString(timezone ...string) string { // ToShortTimeString outputs a string in "150405" layout. func (c *Carbon) ToShortTimeString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -376,7 +376,7 @@ func (c *Carbon) ToShortTimeString(timezone ...string) string { // ToShortTimeMilliString outputs a string in "150405.999" layout. func (c *Carbon) ToShortTimeMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -387,7 +387,7 @@ func (c *Carbon) ToShortTimeMilliString(timezone ...string) string { // ToShortTimeMicroString outputs a string in "150405.999999" layout. func (c *Carbon) ToShortTimeMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -398,7 +398,7 @@ func (c *Carbon) ToShortTimeMicroString(timezone ...string) string { // ToShortTimeNanoString outputs a string in "150405.999999999" layout. func (c *Carbon) ToShortTimeNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -409,7 +409,7 @@ func (c *Carbon) ToShortTimeNanoString(timezone ...string) string { // ToAtomString outputs a string in "2006-01-02T15:04:05Z07:00" layout. func (c *Carbon) ToAtomString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -420,7 +420,7 @@ func (c *Carbon) ToAtomString(timezone ...string) string { // ToAnsicString outputs a string in "Mon Jan _2 15:04:05 2006" layout. func (c *Carbon) ToAnsicString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -431,7 +431,7 @@ func (c *Carbon) ToAnsicString(timezone ...string) string { // ToCookieString outputs a string in "Monday, 02-Jan-2006 15:04:05 MST" layout. func (c *Carbon) ToCookieString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -442,7 +442,7 @@ func (c *Carbon) ToCookieString(timezone ...string) string { // ToRssString outputs a string in "Mon, 02 Jan 2006 15:04:05 -0700" format. func (c *Carbon) ToRssString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -453,7 +453,7 @@ func (c *Carbon) ToRssString(timezone ...string) string { // ToW3cString outputs a string in "2006-01-02T15:04:05Z07:00" layout. func (c *Carbon) ToW3cString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -464,7 +464,7 @@ func (c *Carbon) ToW3cString(timezone ...string) string { // ToUnixDateString outputs a string in "Mon Jan _2 15:04:05 MST 2006" layout. func (c *Carbon) ToUnixDateString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -475,7 +475,7 @@ func (c *Carbon) ToUnixDateString(timezone ...string) string { // ToRubyDateString outputs a string in "Mon Jan 02 15:04:05 -0700 2006" layout. func (c *Carbon) ToRubyDateString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -486,7 +486,7 @@ func (c *Carbon) ToRubyDateString(timezone ...string) string { // ToKitchenString outputs a string in "3:04PM" layout. func (c *Carbon) ToKitchenString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -494,10 +494,21 @@ func (c *Carbon) ToKitchenString(timezone ...string) string { return c.StdTime().Format(KitchenLayout) } +// ToHttpString outputs a string in "Mon, 02 Jan 2006 15:04:05 GMT" layout. +func (c *Carbon) ToHttpString(timezone ...string) string { + if len(timezone) > 0 { + c.loc, c.Error = parseTimezone(timezone...) + } + if c.IsInvalid() { + return "" + } + return c.StdTime().Format(HttpLayout) +} + // ToIso8601String outputs a string in "2006-01-02T15:04:05-07:00" layout. func (c *Carbon) ToIso8601String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -508,7 +519,7 @@ func (c *Carbon) ToIso8601String(timezone ...string) string { // ToIso8601MilliString outputs a string in "2006-01-02T15:04:05.999-07:00" layout. func (c *Carbon) ToIso8601MilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -519,7 +530,7 @@ func (c *Carbon) ToIso8601MilliString(timezone ...string) string { // ToIso8601MicroString outputs a string in "2006-01-02T15:04:05.999999-07:00" layout. func (c *Carbon) ToIso8601MicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -530,7 +541,7 @@ func (c *Carbon) ToIso8601MicroString(timezone ...string) string { // ToIso8601NanoString outputs a string in "2006-01-02T15:04:05.999999999-07:00" layout. func (c *Carbon) ToIso8601NanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -541,7 +552,7 @@ func (c *Carbon) ToIso8601NanoString(timezone ...string) string { // ToIso8601ZuluString outputs a string in "2006-01-02T15:04:05Z" layout. func (c *Carbon) ToIso8601ZuluString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -552,7 +563,7 @@ func (c *Carbon) ToIso8601ZuluString(timezone ...string) string { // ToIso8601ZuluMilliString outputs a string in "2006-01-02T15:04:05.999Z" layout. func (c *Carbon) ToIso8601ZuluMilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -563,7 +574,7 @@ func (c *Carbon) ToIso8601ZuluMilliString(timezone ...string) string { // ToIso8601ZuluMicroString outputs a string in "2006-01-02T15:04:05.999999Z" layout. func (c *Carbon) ToIso8601ZuluMicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -574,7 +585,7 @@ func (c *Carbon) ToIso8601ZuluMicroString(timezone ...string) string { // ToIso8601ZuluNanoString outputs a string in "2006-01-02T15:04:05.999999999Z" layout. func (c *Carbon) ToIso8601ZuluNanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -585,7 +596,7 @@ func (c *Carbon) ToIso8601ZuluNanoString(timezone ...string) string { // ToRfc822String outputs a string in "02 Jan 06 15:04 MST" layout. func (c *Carbon) ToRfc822String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -596,7 +607,7 @@ func (c *Carbon) ToRfc822String(timezone ...string) string { // ToRfc822zString outputs a string in "02 Jan 06 15:04 -0700" layout. func (c *Carbon) ToRfc822zString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -607,7 +618,7 @@ func (c *Carbon) ToRfc822zString(timezone ...string) string { // ToRfc850String outputs a string in "Monday, 02-Jan-06 15:04:05 MST" layout. func (c *Carbon) ToRfc850String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -618,7 +629,7 @@ func (c *Carbon) ToRfc850String(timezone ...string) string { // ToRfc1036String outputs a string in "Mon, 02 Jan 06 15:04:05 -0700" layout. func (c *Carbon) ToRfc1036String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -629,7 +640,7 @@ func (c *Carbon) ToRfc1036String(timezone ...string) string { // ToRfc1123String outputs a string in "Mon, 02 Jan 2006 15:04:05 MST" layout. func (c *Carbon) ToRfc1123String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -640,7 +651,7 @@ func (c *Carbon) ToRfc1123String(timezone ...string) string { // ToRfc1123zString outputs a string in "Mon, 02 Jan 2006 15:04:05 -0700" layout. func (c *Carbon) ToRfc1123zString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -651,7 +662,7 @@ func (c *Carbon) ToRfc1123zString(timezone ...string) string { // ToRfc2822String outputs a string in "Mon, 02 Jan 2006 15:04:05 -0700" layout. func (c *Carbon) ToRfc2822String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -662,7 +673,7 @@ func (c *Carbon) ToRfc2822String(timezone ...string) string { // ToRfc3339String outputs a string in "2006-01-02T15:04:05Z07:00" layout. func (c *Carbon) ToRfc3339String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -673,7 +684,7 @@ func (c *Carbon) ToRfc3339String(timezone ...string) string { // ToRfc3339MilliString outputs a string in "2006-01-02T15:04:05.999Z07:00" layout. func (c *Carbon) ToRfc3339MilliString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -684,7 +695,7 @@ func (c *Carbon) ToRfc3339MilliString(timezone ...string) string { // ToRfc3339MicroString outputs a string in "2006-01-02T15:04:05.999999Z07:00" layout. func (c *Carbon) ToRfc3339MicroString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -695,7 +706,7 @@ func (c *Carbon) ToRfc3339MicroString(timezone ...string) string { // ToRfc3339NanoString outputs a string in "2006-01-02T15:04:05.999999999Z07:00" layout. func (c *Carbon) ToRfc3339NanoString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -706,7 +717,7 @@ func (c *Carbon) ToRfc3339NanoString(timezone ...string) string { // ToRfc7231String outputs a string in "Mon, 02 Jan 2006 15:04:05 GMT" layout. func (c *Carbon) ToRfc7231String(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -717,7 +728,7 @@ func (c *Carbon) ToRfc7231String(timezone ...string) string { // ToFormattedDateString outputs a string in "Jan 2, 2006" layout. func (c *Carbon) ToFormattedDateString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -728,7 +739,7 @@ func (c *Carbon) ToFormattedDateString(timezone ...string) string { // ToFormattedDayDateString outputs a string in "Mon, Jan 2, 2006" layout. func (c *Carbon) ToFormattedDayDateString(timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -739,7 +750,7 @@ func (c *Carbon) ToFormattedDayDateString(timezone ...string) string { // Layout outputs a string by layout. func (c *Carbon) Layout(layout string, timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" @@ -760,7 +771,7 @@ func (c *Carbon) Layout(layout string, timezone ...string) string { // Format outputs a string by format. func (c *Carbon) Format(format string, timezone ...string) string { if len(timezone) > 0 { - c.loc, c.Error = parseTimezone(timezone[0]) + c.loc, c.Error = parseTimezone(timezone...) } if c.IsInvalid() { return "" diff --git a/vendor/github.com/dromara/carbon/v2/parser.go b/vendor/github.com/dromara/carbon/v2/parser.go index 6b799db9..57306f23 100644 --- a/vendor/github.com/dromara/carbon/v2/parser.go +++ b/vendor/github.com/dromara/carbon/v2/parser.go @@ -12,7 +12,7 @@ func Parse(value string, timezone ...string) *Carbon { if value == "" { return &Carbon{isEmpty: true} } - loc, err := getLocation(timezone...) + loc, err := parseTimezone(timezone...) if err != nil { return &Carbon{Error: err} } @@ -49,7 +49,7 @@ func ParseByLayout(value, layout string, timezone ...string) *Carbon { return &Carbon{Error: ErrEmptyLayout()} } - loc, err := getLocation(timezone...) + loc, err := parseTimezone(timezone...) if err != nil { return &Carbon{Error: err} } @@ -76,7 +76,7 @@ func ParseByFormat(value, format string, timezone ...string) *Carbon { if format == "" { return &Carbon{Error: ErrEmptyFormat()} } - loc, err := getLocation(timezone...) + loc, err := parseTimezone(timezone...) if err != nil { return &Carbon{Error: err} } @@ -105,7 +105,7 @@ func ParseByLayouts(value string, layouts []string, timezone ...string) *Carbon return &Carbon{Error: ErrEmptyLayout()} } - loc, err := getLocation(timezone...) + loc, err := parseTimezone(timezone...) if err != nil { return &Carbon{Error: err} } @@ -133,7 +133,7 @@ func ParseByFormats(value string, formats []string, timezone ...string) *Carbon return &Carbon{Error: ErrEmptyFormat()} } - loc, err := getLocation(timezone...) + loc, err := parseTimezone(timezone...) if err != nil { return &Carbon{Error: err} } @@ -150,14 +150,3 @@ func ParseByFormats(value string, formats []string, timezone ...string) *Carbon c.Error = ErrFailedParse(value) return c } - -// getLocation parses and returns location from timezone parameter with fallback to default. -func getLocation(timezone ...string) (*Location, error) { - var tz string - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - return parseTimezone(tz) -} diff --git a/vendor/github.com/dromara/carbon/v2/traveler.go b/vendor/github.com/dromara/carbon/v2/traveler.go index 7f9c6cfe..c36a266b 100644 --- a/vendor/github.com/dromara/carbon/v2/traveler.go +++ b/vendor/github.com/dromara/carbon/v2/traveler.go @@ -7,16 +7,10 @@ import ( // Now returns a Carbon instance for now. func Now(timezone ...string) *Carbon { var ( - tz string loc *Location err error ) - if len(timezone) > 0 { - tz = timezone[0] - } else { - tz = DefaultTimezone - } - if loc, err = parseTimezone(tz); err != nil { + if loc, err = parseTimezone(timezone...); err != nil { return &Carbon{Error: err} } if IsTestNow() { diff --git a/vendor/github.com/dromara/carbon/v2/interfaces.go b/vendor/github.com/dromara/carbon/v2/type_interface.go similarity index 100% rename from vendor/github.com/dromara/carbon/v2/interfaces.go rename to vendor/github.com/dromara/carbon/v2/type_interface.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 82346929..ad65bc82 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -136,7 +136,7 @@ github.com/docker/go-connections/tlsconfig # github.com/docker/go-units v0.5.0 ## explicit github.com/docker/go-units -# github.com/dromara/carbon/v2 v2.6.14 +# github.com/dromara/carbon/v2 v2.6.15 ## explicit; go 1.18 github.com/dromara/carbon/v2 github.com/dromara/carbon/v2/calendar