From ca9fd02ec7fd9397739d4d38964ed17ac7da9551 Mon Sep 17 00:00:00 2001 From: xichen2020 Date: Fri, 9 Dec 2016 17:57:45 -0500 Subject: [PATCH] Add time unit minute (#29) --- src/m3x/time/unit.go | 3 +++ src/m3x/time/unit_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/m3x/time/unit.go b/src/m3x/time/unit.go index 3d4e354852..4509c42c97 100644 --- a/src/m3x/time/unit.go +++ b/src/m3x/time/unit.go @@ -33,6 +33,7 @@ const ( Millisecond Microsecond Nanosecond + Minute ) var ( @@ -81,6 +82,7 @@ var ( Millisecond: "ms", Nanosecond: "ns", Microsecond: "us", + Minute: "m", } durationsToUnit = make(map[time.Duration]Unit) @@ -89,6 +91,7 @@ var ( Millisecond: time.Millisecond, Nanosecond: time.Nanosecond, Microsecond: time.Microsecond, + Minute: time.Minute, } ) diff --git a/src/m3x/time/unit_test.go b/src/m3x/time/unit_test.go index 2938fa5c58..bc59c59993 100644 --- a/src/m3x/time/unit_test.go +++ b/src/m3x/time/unit_test.go @@ -37,6 +37,7 @@ func TestUnitValue(t *testing.T) { {Millisecond, time.Millisecond}, {Microsecond, time.Microsecond}, {Nanosecond, time.Nanosecond}, + {Minute, time.Minute}, } for _, input := range inputs { v, err := input.u.Value() @@ -58,6 +59,7 @@ func TestUnitIsValid(t *testing.T) { {Millisecond, true}, {Microsecond, true}, {Nanosecond, true}, + {Minute, true}, {Unit(10), false}, } for _, input := range inputs { @@ -74,6 +76,7 @@ func TestUnitFromDuration(t *testing.T) { {time.Millisecond, Millisecond}, {time.Microsecond, Microsecond}, {time.Nanosecond, Nanosecond}, + {time.Minute, Minute}, } for _, input := range inputs { u, err := UnitFromDuration(input.d) @@ -96,6 +99,7 @@ func TestUnitString(t *testing.T) { {Millisecond, "ms"}, {Microsecond, "us"}, {Nanosecond, "ns"}, + {Minute, "m"}, {None, "unknown"}, }