mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
chore(deps): bump github.com/dromara/carbon/v2 from 2.6.14 to 2.6.15
Bumps [github.com/dromara/carbon/v2](https://github.com/dromara/carbon) from 2.6.14 to 2.6.15. - [Release notes](https://github.com/dromara/carbon/releases) - [Commits](https://github.com/dromara/carbon/compare/v2.6.14...v2.6.15) --- updated-dependencies: - dependency-name: github.com/dromara/carbon/v2 dependency-version: 2.6.15 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
2
go.mod
2
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
|
||||
|
||||
4
go.sum
4
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=
|
||||
|
||||
16
vendor/github.com/dromara/carbon/v2/README.cn.md
generated
vendored
16
vendor/github.com/dromara/carbon/v2/README.cn.md
generated
vendored
@@ -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`) 项目
|
||||
|
||||
<img src="https://carbon.go-pkg.com/gvp.jpg?v=2.6.x" width="100%" alt="gvp"/>
|
||||
<img src="https://carbon.go-pkg.com/gstar.jpg?v=2.6.x" width="100%" alt="g-star"/>
|
||||
<a href="https://github.com/docker/docker-language-server/blob/main/go.mod#L10" target="_blank"><img src="https://carbon.go-pkg.com/docker.jpg" width="100%" alt="docker"/></a>
|
||||
<a href="https://gitee.com/dromara/carbon" target="_blank"><img src="https://carbon.go-pkg.com/gvp.jpg" width="100%" alt="gvp"/></a>
|
||||
<a href="https://gitcode.com/dromara/carbon" target="_blank"><img src="https://carbon.go-pkg.com/gstar.jpg" width="100%" alt="g-star"/></a>
|
||||
|
||||
## 仓库地址
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
|
||||
### 安装使用
|
||||
|
||||
> go version >= 1.18
|
||||
> go version >= 1.19
|
||||
|
||||
```go
|
||||
// 使用 github 库
|
||||
@@ -102,9 +103,12 @@ carbon.IsTestNow() // false
|
||||
|
||||
<a href="https://github.com/dromara/carbon/graphs/contributors"><img src="https://contrib.rocks/image?repo=dromara/carbon&max=100&columns=16"/></a>
|
||||
|
||||
[如何为 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)
|
||||
|
||||
|
||||
21
vendor/github.com/dromara/carbon/v2/README.ja.md
generated
vendored
21
vendor/github.com/dromara/carbon/v2/README.ja.md
generated
vendored
@@ -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") にも収録されています。
|
||||
|
||||
<a href="https://github.com/docker/docker-language-server/blob/main/go.mod#L10" target="_blank"><img src="https://carbon.go-pkg.com/docker.jpg" width="100%" alt="docker"/></a>
|
||||
|
||||
## リポジトリ
|
||||
|
||||
@@ -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
|
||||
```
|
||||
詳細については <a href="https://carbon.go-pkg.com/ja" target="_blank">公式ドキュメント</a>
|
||||
より多くの使用例については、<a href="https://carbon.go-pkg.com" target="_blank">公式ドキュメント</a>をご覧ください。
|
||||
|
||||
より多くの使用例については、<a href="https://carbon.go-pkg.com/ja" target="_blank">公式ドキュメント</a>をご覧ください。性能テストレポートについては、[分析レポート](docs/BENCHMARK.ja.md)をご参照ください
|
||||
性能テストレポートについては、[ベンチマークレポート](docs/BENCHMARK.ja.md)をご参照ください
|
||||
|
||||
## リファレンス
|
||||
|
||||
@@ -96,7 +98,10 @@ carbon.IsTestNow() // false
|
||||
|
||||
<a href="https://github.com/dromara/carbon/graphs/contributors"><img src="https://contrib.rocks/image?repo=dromara/carbon&max=100&columns=16"/></a>
|
||||
|
||||
[Carbon に新しいローカライズ言語サポートを追加する方法](docs/CONTRIBUTING.ja.md)
|
||||
## 翻訳者
|
||||
`Carbon` を他のローカライズ言語に翻訳してくださる方を募集しています
|
||||
|
||||
[Carbon に新しいローカライズ言語サポートを追加する方法](https://carbon.go-pkg.com/ja/appendix/contribution-guide.html)
|
||||
|
||||
## スポンサー
|
||||
|
||||
|
||||
19
vendor/github.com/dromara/carbon/v2/README.ko.md
generated
vendored
19
vendor/github.com/dromara/carbon/v2/README.ko.md
generated
vendored
@@ -9,11 +9,13 @@
|
||||
[](https://hellogithub.com/en/repository/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")에도 수록되어 있습니다.
|
||||
|
||||
<a href="https://github.com/docker/docker-language-server/blob/main/go.mod#L10" target="_blank"><img src="https://carbon.go-pkg.com/docker.jpg" width="100%" alt="docker"/></a>
|
||||
|
||||
## 저장소
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
더 많은 사용 예시는 <a href="https://carbon.go-pkg.com/ko" target="_blank">공식 문서</a>를 참조하세요. 성능 테스트 보고서는 [분석 보고서](docs/BENCHMARK.ko.md)를 참조하세요.
|
||||
더 많은 사용 예시는 <a href="https://carbon.go-pkg.com" target="_blank">공식 문서</a>를 참조하세요.
|
||||
|
||||
성능 테스트 보고서는 [벤치마크 보고서](docs/BENCHMARK.ko.md)를 참조하세요.
|
||||
|
||||
## 참고 자료
|
||||
|
||||
@@ -95,7 +99,10 @@ carbon.IsTestNow() // false
|
||||
|
||||
<a href="https://github.com/dromara/carbon/graphs/contributors"><img src="https://contrib.rocks/image?repo=dromara/carbon&max=100&columns=16" /></a>
|
||||
|
||||
[Carbon에 새로운 로컬라이즈드 언어 지원을 추가하는 방법](docs/CONTRIBUTING.ko.md)
|
||||
## 번역자
|
||||
`Carbon` 을 더 많은 로컬라이즈드 언어로 번역하는 데 도움을 요청드립니다
|
||||
|
||||
[Carbon에 새로운 로컬라이즈드 언어 지원을 추가하는 방법](https://carbon.go-pkg.com/ko/appendix/contribution-guide.html)
|
||||
|
||||
## 스폰서
|
||||
|
||||
|
||||
19
vendor/github.com/dromara/carbon/v2/README.md
generated
vendored
19
vendor/github.com/dromara/carbon/v2/README.md
generated
vendored
@@ -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").
|
||||
|
||||
<a href="https://github.com/docker/docker-language-server/blob/main/go.mod#L10" target="_blank"><img src="https://carbon.go-pkg.com/docker.jpg" width="100%" alt="docker"/></a>
|
||||
|
||||
## 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`:
|
||||
|
||||
<a href="https://github.com/dromara/carbon/graphs/contributors"><img src="https://contrib.rocks/image?repo=dromara/carbon&max=100&columns=16" /></a>
|
||||
|
||||
[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
|
||||
|
||||
|
||||
5
vendor/github.com/dromara/carbon/v2/constants.go
generated
vendored
5
vendor/github.com/dromara/carbon/v2/constants.go
generated
vendored
@@ -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"
|
||||
|
||||
42
vendor/github.com/dromara/carbon/v2/creator.go
generated
vendored
42
vendor/github.com/dromara/carbon/v2/creator.go
generated
vendored
@@ -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))
|
||||
|
||||
10
vendor/github.com/dromara/carbon/v2/difference.go
generated
vendored
10
vendor/github.com/dromara/carbon/v2/difference.go
generated
vendored
@@ -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.
|
||||
|
||||
20
vendor/github.com/dromara/carbon/v2/helper.go
generated
vendored
20
vendor/github.com/dromara/carbon/v2/helper.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
||||
|
||||
22
vendor/github.com/dromara/carbon/v2/lang/af.json
generated
vendored
Normal file
22
vendor/github.com/dromara/carbon/v2/lang/af.json
generated
vendored
Normal file
@@ -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"
|
||||
}
|
||||
22
vendor/github.com/dromara/carbon/v2/lang/mn.json
generated
vendored
Normal file
22
vendor/github.com/dromara/carbon/v2/lang/mn.json
generated
vendored
Normal file
@@ -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 дараа"
|
||||
}
|
||||
2
vendor/github.com/dromara/carbon/v2/lang/nb.json
generated
vendored
2
vendor/github.com/dromara/carbon/v2/lang/nb.json
generated
vendored
@@ -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",
|
||||
|
||||
2
vendor/github.com/dromara/carbon/v2/lang/nl.json
generated
vendored
2
vendor/github.com/dromara/carbon/v2/lang/nl.json
generated
vendored
@@ -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",
|
||||
|
||||
135
vendor/github.com/dromara/carbon/v2/outputer.go
generated
vendored
135
vendor/github.com/dromara/carbon/v2/outputer.go
generated
vendored
@@ -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 ""
|
||||
|
||||
21
vendor/github.com/dromara/carbon/v2/parser.go
generated
vendored
21
vendor/github.com/dromara/carbon/v2/parser.go
generated
vendored
@@ -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)
|
||||
}
|
||||
|
||||
8
vendor/github.com/dromara/carbon/v2/traveler.go
generated
vendored
8
vendor/github.com/dromara/carbon/v2/traveler.go
generated
vendored
@@ -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() {
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user