Compare commits

...

2 Commits

@ -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.9
```
#### 使用

@ -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分"
)

@ -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))
}

@ -1,3 +1,3 @@
module go.dtapp.net/gotime
go 1.18
go 1.22

@ -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"

@ -91,6 +91,15 @@ func (p Pro) Format() string {
return p.Time.Format(DateTimeFormat)
}
// FormatFilter 今天此刻格式化 带 过滤无效时间
func (p Pro) FormatFilter() string {
if p.Time.Format(DateTimeFormat) == "0001-01-01 00:00:00" || p.Time.Format(DateTimeFormat) == "0001-01-01 08:05:43" {
return ""
} else {
return p.Time.Format(DateTimeFormat)
}
}
// ToDateFormat 今天此刻日期
func (p Pro) ToDateFormat() string {
return p.Time.Format(DateFormat)

@ -1,3 +1,3 @@
package gotime
const Version = "1.0.7"
const Version = "1.0.9"

Loading…
Cancel
Save