diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go index e2e9ff574..548968aeb 100644 --- a/vendor/github.com/prometheus/common/model/time.go +++ b/vendor/github.com/prometheus/common/model/time.go @@ -163,10 +163,10 @@ func (t *Time) UnmarshalJSON(b []byte) error { // This type should not propagate beyond the scope of input/output processing. type Duration time.Duration -var durationRE = regexp.MustCompile("^([0-9]+)(d|h|m|s|ms)$") +var durationRE = regexp.MustCompile("^([0-9]+)(y|w|d|h|m|s|ms)$") // StringToDuration parses a string into a time.Duration, assuming that a year -// a day always has 24h. +// always has 365d, a week always has 7d, and a day always has 24h. func ParseDuration(durationStr string) (Duration, error) { matches := durationRE.FindStringSubmatch(durationStr) if len(matches) != 3 { @@ -177,6 +177,10 @@ func ParseDuration(durationStr string) (Duration, error) { dur = time.Duration(n) * time.Millisecond ) switch unit := matches[2]; unit { + case "y": + dur *= 1000 * 60 * 60 * 24 * 365 + case "w": + dur *= 1000 * 60 * 60 * 24 * 7 case "d": dur *= 1000 * 60 * 60 * 24 case "h": @@ -199,6 +203,8 @@ func (d Duration) String() string { unit = "ms" ) factors := map[string]int64{ + "y": 1000 * 60 * 60 * 24 * 365, + "w": 1000 * 60 * 60 * 24 * 7, "d": 1000 * 60 * 60 * 24, "h": 1000 * 60 * 60, "m": 1000 * 60, @@ -207,6 +213,10 @@ func (d Duration) String() string { } switch int64(0) { + case ms % factors["y"]: + unit = "y" + case ms % factors["w"]: + unit = "w" case ms % factors["d"]: unit = "d" case ms % factors["h"]: diff --git a/vendor/vendor.json b/vendor/vendor.json index a5c1ee115..f2405ebab 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -174,8 +174,8 @@ }, { "path": "github.com/prometheus/common/model", - "revision": "b0d797186bfbaf6d785031c6c2d32f75c720007d", - "revisionTime": "2016-01-22T12:15:42+01:00" + "revision": "0e53cc19aa67dd2e8587a26e28643cb152f5403d", + "revisionTime": "2016-01-29T15:16:16+01:00" }, { "path": "github.com/prometheus/common/route",