feat: 增强 time helper
This commit is contained in:
parent
2450be244e
commit
6ba1050711
@ -24,3 +24,26 @@ func FormatDt(ts int64) string {
|
||||
func FormatDateTime(ts int64) string {
|
||||
return Format(ts, "2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func IsUnixZero(t time.Time) bool {
|
||||
return t.Unix() == 0
|
||||
}
|
||||
|
||||
func GetTimeUTCPointer() *time.Time {
|
||||
t := time.Now().UTC()
|
||||
return &t
|
||||
}
|
||||
|
||||
func TimeToPointer(t time.Time) *time.Time {
|
||||
if t.IsZero() {
|
||||
return nil
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func UnixToTimePointer(v int64) *time.Time {
|
||||
if v == 0 {
|
||||
return nil
|
||||
}
|
||||
return TimeToPointer(time.Unix(v, 0))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user