|
|
|
@ -25,6 +25,18 @@ func GetUnixNow() Timestamp {
|
|
|
|
|
return Timestamp(time.Now().Unix())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetUnix 嘗試取得時間戳記
|
|
|
|
|
func GetUnix(format, datetime string) (Timestamp, error) {
|
|
|
|
|
t, err := time.Parse(format, datetime)
|
|
|
|
|
return Timestamp(t.Unix()), err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MustGetUnix 強制取得時間戳記
|
|
|
|
|
func MustGetUnix(format, datetime string) Timestamp {
|
|
|
|
|
t, _ := GetUnix(format, datetime)
|
|
|
|
|
return t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Int64 轉為64位元整數
|
|
|
|
|
func (t Timestamp) Int64() int64 {
|
|
|
|
|
return int64(t)
|
|
|
|
|