Skip to content

Commit

Permalink
feat:增加时间相关函数
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyIsMe committed Oct 8, 2022
1 parent 524cd14 commit 97b06ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions time/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,18 @@ func BeginOfYear(t time.Time) time.Time {
func EndOfYear(t time.Time) time.Time {
return BeginOfYear(t).AddDate(1, 0, 0).Add(-time.Nanosecond)
}

// FomratTime 格式化时间
func FomratTime(unformatTime string) string {
fomatTime := ""
for i := 0; i < len(unformatTime); i++ {
if unformatTime[i] == 'T' {
fomatTime = fmt.Sprintf("%s ", fomatTime)
} else if unformatTime[i] == 'Z' {
continue
} else {
fomatTime = fmt.Sprintf("%s%c", fomatTime, unformatTime[i])
}
}
return fomatTime
}

0 comments on commit 97b06ab

Please sign in to comment.