github.com/argoproj/argo-cd/v3@v3.2.1/util/notification/expression/time/time.go (about) 1 package time 2 3 import ( 4 "time" 5 ) 6 7 var now = time.Now 8 9 func NewExprs() map[string]any { 10 return map[string]any{ 11 // Functions 12 "Parse": parse, 13 "Now": now, 14 // Durations 15 "Nanosecond": time.Nanosecond, 16 "Microsecond": time.Microsecond, 17 "Millisecond": time.Millisecond, 18 "Second": time.Second, 19 "Minute": time.Minute, 20 "Hour": time.Hour, 21 // Timestamps 22 "Layout": time.Layout, 23 "ANSIC": time.ANSIC, 24 "UnixDate": time.UnixDate, 25 "RubyDate": time.RubyDate, 26 "RFC822": time.RFC822, 27 "RFC822Z": time.RFC822Z, 28 "RFC850": time.RFC850, 29 "RFC1123": time.RFC1123, 30 "RFC1123Z": time.RFC1123Z, 31 "RFC3339": time.RFC3339, 32 "RFC3339Nano": time.RFC3339Nano, 33 "Kitchen": time.Kitchen, 34 "Stamp": time.Stamp, 35 "StampMilli": time.StampMilli, 36 "StampMicro": time.StampMicro, 37 "StampNano": time.StampNano, 38 } 39 } 40 41 func parse(timestamp string) time.Time { 42 res, err := time.Parse(time.RFC3339, timestamp) 43 if err != nil { 44 panic(err) 45 } 46 return res 47 }