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)
| 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. |
| 48 | func 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. |
nothing calls this directly
no test coverage detected