feat: time util

This commit is contained in:
Bobo
2025-05-28 23:55:43 +08:00
parent 89a69a9d4d
commit faa5817857
4 changed files with 19 additions and 2 deletions

View File

@@ -172,6 +172,14 @@ func TimeToDateString(tm *time.Time) *string {
return trans.String(tm.In(GetDefaultTimeLocation()).Format(DateLayout))
}
func TimeToDateStringWithLayout(tm *time.Time, layout string) *string {
if tm == nil {
return nil
}
return trans.String(tm.Format(layout))
}
// TimestamppbToTime timestamppb.Timestamp -> time.Time
func TimestamppbToTime(timestamp *timestamppb.Timestamp) *time.Time {
if timestamp != nil {