diff --git a/clock/clock.go b/clock/clock.go index 591563a1..a2083019 100644 --- a/clock/clock.go +++ b/clock/clock.go @@ -20,6 +20,10 @@ import ( // negative values. However, for such lengths of time, a fixed 24 hours per day // is assumed and a modulo operation Mod24 is provided to discard whole multiples of 24 hours. // +// Clock is a type of integer (actually int32), so values can be compared and sorted as +// per other integers. The constants Second, Minute, Hour and Day can be added and subtracted +// with obvious outcomes. +// // See https://en.wikipedia.org/wiki/ISO_8601#Times type Clock int32 diff --git a/clock/clock_test.go b/clock/clock_test.go index e9bdc675..0d629167 100644 --- a/clock/clock_test.go +++ b/clock/clock_test.go @@ -269,6 +269,8 @@ func TestClockParseGoods(t *testing.T) { {"01:00", New(1, 0, 0, 0)}, {"01:02", New(1, 2, 0, 0)}, {"23:59", New(23, 59, 0, 0)}, + {"0911", New(9, 11, 0, 0)}, + {"1024", New(10, 24, 0, 0)}, {"2359", New(23, 59, 0, 0)}, {"00:00:00", New(0, 0, 0, 0)}, {"00:00:01", New(0, 0, 1, 0)}, @@ -297,10 +299,14 @@ func TestClockParseGoods(t *testing.T) { {"1am", New(1, 0, 0, 0)}, {"1pm", New(13, 0, 0, 0)}, {"1:00am", New(1, 0, 0, 0)}, - {"1:00pm", New(13, 0, 0, 0)}, + {"1:23am", New(1, 23, 0, 0)}, + {"1:23pm", New(13, 23, 0, 0)}, + {"01:23pm", New(13, 23, 0, 0)}, {"1:00:00am", New(1, 0, 0, 0)}, {"1:02:03pm", New(13, 2, 3, 0)}, + {"01:02:03pm", New(13, 2, 3, 0)}, {"1:02:03.004pm", New(13, 2, 3, 4)}, + {"01:02:03.004pm", New(13, 2, 3, 4)}, {"1:20:30.04pm", New(13, 20, 30, 40)}, {"1:20:30.4pm", New(13, 20, 30, 400)}, {"1:20:30.pm", New(13, 20, 30, 0)},