feat: time util
This commit is contained in:
@@ -172,7 +172,7 @@ func TimeToDateString(tm *time.Time) *string {
|
|||||||
return trans.String(tm.In(GetDefaultTimeLocation()).Format(DateLayout))
|
return trans.String(tm.In(GetDefaultTimeLocation()).Format(DateLayout))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TimeToDateStringWithLayout(tm *time.Time, layout string) *string {
|
func TimeToString(tm *time.Time, layout string) *string {
|
||||||
if tm == nil {
|
if tm == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,13 +149,13 @@ func TestTimeToDateString(t *testing.T) {
|
|||||||
assert.Nil(t, result)
|
assert.Nil(t, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTimeToDateStringWithLayout(t *testing.T) {
|
func TestTimeToString(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
fmt.Println(*TimeToDateStringWithLayout(&now, DateLayout))
|
fmt.Println(*TimeToString(&now, DateLayout))
|
||||||
fmt.Println(*TimeToDateStringWithLayout(&now, ISO8601))
|
fmt.Println(*TimeToString(&now, ISO8601))
|
||||||
fmt.Println(*TimeToDateStringWithLayout(&now, ISO8601TZHour))
|
fmt.Println(*TimeToString(&now, ISO8601TZHour))
|
||||||
fmt.Println(*TimeToDateStringWithLayout(&now, ISO8601NoTZ))
|
fmt.Println(*TimeToString(&now, ISO8601NoTZ))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTimestamppbToTime(t *testing.T) {
|
func TestTimestamppbToTime(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user