diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-08-26 14:43:10 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-08-26 14:43:10 +0200 |
commit | bac5337e6584a7201ba73be64dee3922721aba5a (patch) | |
tree | f1db5bd984c7bada192b1786006a527ebfe4916c /chronos/chronos.go | |
parent | f94eab4b4b830ac47f20e6d91b02c0a01584becf (diff) | |
download | mailremind-bac5337e6584a7201ba73be64dee3922721aba5a.tar.gz mailremind-bac5337e6584a7201ba73be64dee3922721aba5a.tar.bz2 mailremind-bac5337e6584a7201ba73be64dee3922721aba5a.zip |
NilTime -> nilTime
So users can not manipulate that variable
Also added some documentation
Diffstat (limited to 'chronos/chronos.go')
-rw-r--r-- | chronos/chronos.go | 12 |
1 files changed, 7 insertions, 5 deletions
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... } |