Browse Source

Update common/model vendoring

pull/1357/head
beorn7 9 years ago
parent
commit
cfc15cf103
  1. 14
      vendor/github.com/prometheus/common/model/time.go
  2. 4
      vendor/vendor.json

14
vendor/github.com/prometheus/common/model/time.go generated vendored

@ -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"]:

4
vendor/vendor.json vendored

@ -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",

Loading…
Cancel
Save