Permalink
Browse files

opentsdb: have opentsdb.Duration implement encoding.TextUnmarshaler

  • Loading branch information...
1 parent 3aa8820 commit e9697262ab8511661c0139d6a64b8619c88cd341 @alienth alienth committed with kylebrandt Dec 1, 2016
Showing with 10 additions and 0 deletions.
  1. +10 −0 opentsdb/duration.go
View
@@ -174,3 +174,13 @@ func (d Duration) HumanString() string {
func (d Duration) Seconds() float64 {
return time.Duration(d).Seconds()
}
+
+func (d *Duration) UnmarshalText(text []byte) error {
+ duration, err := ParseDuration(string(text))
+ if err != nil {
+ return err
+ }
+
+ *d = duration
+ return nil
+}

0 comments on commit e969726

Please sign in to comment.