MCPcopy Create free account
hub / github.com/cel-expr/cel-go / legacyStringToTimestamp

Function legacyStringToTimestamp

cel/timestamp_legacy.go:48–61  ·  view source on GitHub ↗

legacyStringToTimestamp converts a string to a timestamp the way cel-go did before v0.30.0: any string accepted by time.Parse(time.RFC3339, ...) is accepted.

(val ref.Val)

Source from the content-addressed store, hash-verified

46// legacyStringToTimestamp converts a string to a timestamp the way cel-go did before v0.30.0:
47// any string accepted by time.Parse(time.RFC3339, ...) is accepted.
48func legacyStringToTimestamp(val ref.Val) ref.Val {
49 s, ok := val.(types.String)
50 if !ok {
51 return types.MaybeNoSuchOverloadErr(val)
52 }
53 t, err := time.Parse(time.RFC3339, string(s))
54 if err != nil {
55 return types.NewErr("type conversion error from '%s' to '%s'", types.StringType, types.TimestampType)
56 }
57 if t.Unix() < legacyMinUnixTime || t.Unix() > legacyMaxUnixTime {
58 return types.NewErr("timestamp overflow")
59 }
60 return types.Timestamp{Time: t}
61}
62
63// legacyInTimeZone resolves a timezone argument the way cel-go did before v0.31.0: numeric
64// offsets of the form [+-]HH:MM are not range checked.

Callers

nothing calls this directly

Calls 3

MaybeNoSuchOverloadErrFunction · 0.92
NewErrFunction · 0.92
ParseMethod · 0.65

Tested by

no test coverage detected