(s string)
| 228 | } |
| 229 | |
| 230 | func ParseDurationMs(s string) (int64, error) { |
| 231 | if d, err := strconv.ParseFloat(s, 64); err == nil { |
| 232 | ts := d * float64(time.Second/time.Millisecond) |
| 233 | if ts > float64(math.MaxInt64) || ts < float64(math.MinInt64) { |
| 234 | return 0, httpgrpc.Errorf(http.StatusBadRequest, "cannot parse %q to a valid duration. It overflows int64", s) |
| 235 | } |
| 236 | return int64(ts), nil |
| 237 | } |
| 238 | if d, err := model.ParseDuration(s); err == nil { |
| 239 | return int64(d) / int64(time.Millisecond/time.Nanosecond), nil |
| 240 | } |
| 241 | return 0, httpgrpc.Errorf(http.StatusBadRequest, "cannot parse %q to a valid duration", s) |
| 242 | } |
| 243 | |
| 244 | func DurationMilliseconds(d time.Duration) int64 { |
| 245 | return int64(d / (time.Millisecond / time.Nanosecond)) |
no outgoing calls
no test coverage detected