Compare commits

...

2 Commits

@ -13,12 +13,12 @@
#### 安装
```shell
go get -v -u go.dtapp.net/gotime@v1.0.8
go get -v -u go.dtapp.net/gotime@v1.0.10
```
#### 使用
```go
```text
package main
import (

@ -1,16 +1,21 @@
package gotime
const (
DateTimeFormat = "2006-01-02 15:04:05"
DateTimeShrinkFormat = "2006-01-02 15:04"
DateFormat = "2006-01-02"
TimeFormat = "15:04:05"
DateTimeFormat = "2006-01-02 15:04:05"
DateTimeSFormat = "2006-01-0215:04:05"
DateTimeShrinkFormat = "2006-01-02 15:04"
DateTimeShrinkSFormat = "2006-01-0215:04"
DateFormat = "2006-01-02"
TimeFormat = "15:04:05"
TimeShrinkFormat = "15:04"
)
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分"
DateTimeZhFormat = "2006年01月02日 15点04分05秒"
DateTimeZhSFormat = "2006年01月02日15点04分05秒"
DateTimeZhShrinkFormat = "2006年01月02日 15点04分"
DateTimeZhShrinkSFormat = "2006年01月02日15点04分"
DateZhFormat = "2006年01月02日"
TimeZhFormat = "15点04分05秒"
TimeZhShrinkFormat = "15点04分"
)

@ -2,9 +2,21 @@ package gotime
import "testing"
func TestFormat(t *testing.T) {
t.Log("DateTimeFormat", Current().SetFormat(DateTimeFormat))
t.Log("DateTimeSFormat", Current().SetFormat(DateTimeSFormat))
t.Log("DateTimeShrinkFormat", Current().SetFormat(DateTimeShrinkFormat))
t.Log("DateTimeShrinkSFormat", Current().SetFormat(DateTimeShrinkSFormat))
t.Log("DateFormat", Current().SetFormat(DateFormat))
t.Log("TimeFormat", Current().SetFormat(TimeFormat))
t.Log("TimeShrinkFormat", Current().SetFormat(TimeShrinkFormat))
}
func TestZhFormat(t *testing.T) {
t.Log("DateTimeZhFormat", Current().SetFormat(DateTimeZhFormat))
t.Log("DateTimeZhSFormat", Current().SetFormat(DateTimeZhSFormat))
t.Log("DateTimeZhShrinkFormat", Current().SetFormat(DateTimeZhShrinkFormat))
t.Log("DateTimeZhShrinkSFormat", Current().SetFormat(DateTimeZhShrinkSFormat))
t.Log("DateZhFormat", Current().SetFormat(DateZhFormat))
t.Log("TimeZhFormat", Current().SetFormat(TimeZhFormat))
t.Log("TimeZhShrinkFormat", Current().SetFormat(TimeZhShrinkFormat))

@ -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.8"
const Version = "1.0.10"

Loading…
Cancel
Save