Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli committed Feb 12, 2019
1 parent acc3692 commit f636b10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ time的工具集合

获取当日晚上24点(次日0点)的时间

func Get24time(t time.Time) time.Time
func Get24Time(t time.Time) time.Time

获取当日晚上24点(次日0点)的时间戳

func Get24timeUnix(t time.Time) int64
func Get24TimeUnix(t time.Time) int64

获取今天晚上24点(次日0点)的时间戳

func GetToday24timeUnix() int64
func GetToday24TimeUnix() int64

时间转换成日期字符串 (time.Time to "2006-01-02")

Expand Down
14 changes: 7 additions & 7 deletions gotime.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ func GetNowTimeUnix() int64 {
}

// 获取当日晚上24点(次日0点)的时间
func Get24time(t time.Time) time.Time {
func Get24Time(t time.Time) time.Time {
dateStr := TimeToDate(t.Add(time.Hour * 24))
return DateStrToTime(dateStr)
}

// 获取当日晚上24点(次日0点)的时间戳
func Get24timeUnix(t time.Time) int64 {
t24 := Get24time(t)
func Get24TimeUnix(t time.Time) int64 {
t24 := Get24Time(t)
return GetTimeUnix(t24)
}

// 获取今天晚上24点(次日0点)的时间
func GetToday24time() time.Time {
return Get24time(time.Now())
func GetToday24Time() time.Time {
return Get24Time(time.Now())
}

// 获取今天晚上24点(次日0点)的时间戳
func GetToday24timeUnix() int64 {
return Get24timeUnix(time.Now())
func GetToday24TimeUnix() int64 {
return Get24TimeUnix(time.Now())
}

// 时间转换成日期字符串 (time.Time to "2006-01-02")
Expand Down
10 changes: 5 additions & 5 deletions gotime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ func TestGetNowTimeUnix(t *testing.T) {

func TestGet24time(t *testing.T) {
now := time.Now()
time24 := Get24time(now)
time24 := Get24Time(now)
assert.NotZero(t, time24.Unix())
}

func TestGet24timeUnix(t *testing.T) {
now := time.Now()
time24 := Get24time(now)
unix := Get24timeUnix(now)
time24 := Get24Time(now)
unix := Get24TimeUnix(now)
assert.NotZero(t, unix)
assert.Equal(t, unix, time24.Unix())
}

func TestGetToday24time(t *testing.T) {
time24 := GetToday24time()
time24 := GetToday24Time()
assert.NotZero(t, time24.Unix())
}

func TestGetToday24timeUnix(t *testing.T) {
unix := GetToday24timeUnix()
unix := GetToday24TimeUnix()
assert.NotZero(t, unix)
}

Expand Down

0 comments on commit f636b10

Please sign in to comment.