From e25da0cbd405fcc5ea5cf25dd90b7e0d57c6e75c Mon Sep 17 00:00:00 2001 From: dtapps Date: Mon, 18 Mar 2024 10:52:01 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20`ZhFormat`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- format.go | 16 ++++++++++++++++ format_test.go | 11 +++++++++++ go.mod | 2 +- gotime.go | 3 --- version.go | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 format.go create mode 100644 format_test.go diff --git a/README.md b/README.md index 8051baa..f6fc041 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ #### 安装 ```shell -go get -v -u go.dtapp.net/gotime@v1.0.7 +go get -v -u go.dtapp.net/gotime@v1.0.8 ``` #### 使用 diff --git a/format.go b/format.go new file mode 100644 index 0000000..5e23304 --- /dev/null +++ b/format.go @@ -0,0 +1,16 @@ +package gotime + +const ( + DateTimeFormat = "2006-01-02 15:04:05" + DateTimeShrinkFormat = "2006-01-02 15:04" + DateFormat = "2006-01-02" + TimeFormat = "15:04:05" +) + +const ( + DateTimeZhFormat = "2006年01月02日 15点04分05秒" + DateTimeZhShrinkFormat = "2006年01月02日 15点04分" + DateZhFormat = "2006年01月02日" + TimeZhFormat = "15点04分05秒" + TimeZhShrinkFormat = "15点04分" +) diff --git a/format_test.go b/format_test.go new file mode 100644 index 0000000..f6a3818 --- /dev/null +++ b/format_test.go @@ -0,0 +1,11 @@ +package gotime + +import "testing" + +func TestZhFormat(t *testing.T) { + t.Log("DateTimeZhFormat", Current().SetFormat(DateTimeZhFormat)) + t.Log("DateTimeZhShrinkFormat", Current().SetFormat(DateTimeZhShrinkFormat)) + t.Log("DateZhFormat", Current().SetFormat(DateZhFormat)) + t.Log("TimeZhFormat", Current().SetFormat(TimeZhFormat)) + t.Log("TimeZhShrinkFormat", Current().SetFormat(TimeZhShrinkFormat)) +} diff --git a/go.mod b/go.mod index f7f33fd..4e6d67a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module go.dtapp.net/gotime -go 1.18 +go 1.22 diff --git a/gotime.go b/gotime.go index dcb7071..2aba8a4 100644 --- a/gotime.go +++ b/gotime.go @@ -13,9 +13,6 @@ const ( RFC1036Format = "Mon, 02 Jan 06 15:04:05 -0700" RFC7231Format = "Mon, 02 Jan 2006 15:04:05 GMT" DayDateTimeFormat = "Mon, Jan 2, 2006 3:04 PM" - DateTimeFormat = "2006-01-02 15:04:05" - DateFormat = "2006-01-02" - TimeFormat = "15:04:05" ShortDateTimeFormat = "20060102150405" ShortDateFormat = "20060102" ShortTimeFormat = "150405" diff --git a/version.go b/version.go index 7ca4e42..9d15649 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package gotime -const Version = "1.0.7" +const Version = "1.0.8"