Skip to content

Commit

Permalink
Add time unit minute (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
xichen2020 authored and prateek committed Apr 8, 2019
1 parent b50f9da commit ca9fd02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/m3x/time/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
Millisecond
Microsecond
Nanosecond
Minute
)

var (
Expand Down Expand Up @@ -81,6 +82,7 @@ var (
Millisecond: "ms",
Nanosecond: "ns",
Microsecond: "us",
Minute: "m",
}

durationsToUnit = make(map[time.Duration]Unit)
Expand All @@ -89,6 +91,7 @@ var (
Millisecond: time.Millisecond,
Nanosecond: time.Nanosecond,
Microsecond: time.Microsecond,
Minute: time.Minute,
}
)

Expand Down
4 changes: 4 additions & 0 deletions src/m3x/time/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -58,6 +59,7 @@ func TestUnitIsValid(t *testing.T) {
{Millisecond, true},
{Microsecond, true},
{Nanosecond, true},
{Minute, true},
{Unit(10), false},
}
for _, input := range inputs {
Expand All @@ -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)
Expand All @@ -96,6 +99,7 @@ func TestUnitString(t *testing.T) {
{Millisecond, "ms"},
{Microsecond, "us"},
{Nanosecond, "ns"},
{Minute, "m"},
{None, "unknown"},
}

Expand Down

0 comments on commit ca9fd02

Please sign in to comment.