mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package time
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var now = time.Now
|
|
|
|
func NewExprs() map[string]any {
|
|
return map[string]any{
|
|
// Functions
|
|
"Parse": parse,
|
|
"Now": now,
|
|
// Durations
|
|
"Nanosecond": time.Nanosecond,
|
|
"Microsecond": time.Microsecond,
|
|
"Millisecond": time.Millisecond,
|
|
"Second": time.Second,
|
|
"Minute": time.Minute,
|
|
"Hour": time.Hour,
|
|
// Timestamps
|
|
"Layout": time.Layout,
|
|
"ANSIC": time.ANSIC,
|
|
"UnixDate": time.UnixDate,
|
|
"RubyDate": time.RubyDate,
|
|
"RFC822": time.RFC822,
|
|
"RFC822Z": time.RFC822Z,
|
|
"RFC850": time.RFC850,
|
|
"RFC1123": time.RFC1123,
|
|
"RFC1123Z": time.RFC1123Z,
|
|
"RFC3339": time.RFC3339,
|
|
"RFC3339Nano": time.RFC3339Nano,
|
|
"Kitchen": time.Kitchen,
|
|
"Stamp": time.Stamp,
|
|
"StampMilli": time.StampMilli,
|
|
"StampMicro": time.StampMicro,
|
|
"StampNano": time.StampNano,
|
|
}
|
|
}
|
|
|
|
func parse(timestamp string) time.Time {
|
|
res, err := time.Parse(time.RFC3339, timestamp)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return res
|
|
}
|