From bac5337e6584a7201ba73be64dee3922721aba5a Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Mon, 26 Aug 2013 14:43:10 +0200 Subject: NilTime -> nilTime So users can not manipulate that variable Also added some documentation --- chronos/chronos.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'chronos/chronos.go') diff --git a/chronos/chronos.go b/chronos/chronos.go index 18bf775..e66fc76 100644 --- a/chronos/chronos.go +++ b/chronos/chronos.go @@ -16,7 +16,7 @@ const ( Year ) -var NilTime time.Time +var nilTime time.Time func (tu TimeUnit) String() string { switch tu { @@ -123,24 +123,26 @@ func (f Frequency) addTo(t time.Time, mul uint) time.Time { case Year: return time.Date(year+fq, month, day, hour, min, sec, 0, loc) default: - return NilTime + return nilTime } } func (f Frequency) minApprox() time.Duration { return time.Duration(f.Count) * f.Unit.minApprox() } func (f Frequency) maxApprox() time.Duration { return time.Duration(f.Count) * f.Unit.maxApprox() } +// Chronos describes a time schedule. It has a start and optional end point and an optional frequency. type Chronos struct { Start, End time.Time Freq Frequency } +// NextAfter calculates the next time in the schedule after t. If no such time exists, nil is returned (test with Time.IsZero()). func (c Chronos) NextAfter(t time.Time) time.Time { if !t.After(c.Start) { return c.Start } if c.Freq.Count == 0 { - return NilTime + return nilTime } d := t.Sub(c.Start) @@ -154,10 +156,10 @@ func (c Chronos) NextAfter(t time.Time) time.Time { continue } if (!c.End.IsZero()) && t2.After(c.End) { - return NilTime + return nilTime } return t2 } - return NilTime // Should actually never happen... + return nilTime // Should actually never happen... } -- cgit v1.2.3-54-g00ecf