diff --git a/helper/time_helper.go b/helper/time_helper.go index dcfda62..c1fef24 100644 --- a/helper/time_helper.go +++ b/helper/time_helper.go @@ -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)) +}