MCPcopy
hub / github.com/prometheus/prometheus / parseTimeParam

Function parseTimeParam

web/api/v1/api.go:2253–2263  ·  view source on GitHub ↗
(r *http.Request, paramName string, defaultValue time.Time)

Source from the content-addressed store, hash-verified

2251}
2252
2253func parseTimeParam(r *http.Request, paramName string, defaultValue time.Time) (time.Time, error) {
2254 val := r.FormValue(paramName)
2255 if val == "" {
2256 return defaultValue, nil
2257 }
2258 result, err := parseTime(val)
2259 if err != nil {
2260 return time.Time{}, fmt.Errorf("invalid time value for '%s': %w", paramName, err)
2261 }
2262 return result, nil
2263}
2264
2265func parseTime(s string) (time.Time, error) {
2266 if t, err := strconv.ParseFloat(s, 64); err == nil {

Callers 8

queryMethod · 0.85
queryExemplarsMethod · 0.85
labelNamesMethod · 0.85
labelValuesMethod · 0.85
seriesMethod · 0.85
deleteSeriesMethod · 0.85
parseSearchParamsMethod · 0.85
TestParseTimeParamFunction · 0.85

Calls 1

parseTimeFunction · 0.70

Tested by 1

TestParseTimeParamFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…