Skip to content

Commit

Permalink
comments & test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick Beton committed Oct 5, 2018
1 parent 8571bfe commit 9fcad74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion clock/clock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
Expand Down

0 comments on commit 9fcad74

Please sign in to comment.