Documentation
¶
Overview ¶
Package kronos are time utilities.
Index ¶
- func Between(start, end time.Time, interval time.Duration) []time.Time
- func BetweenDates(start, end time.Time, offsetYear, offsetMonth, offsetDay int) []time.Time
- func BetweenDatesEach(start, end time.Time, y, m, d int, each func(time.Time))
- func BetweenEach(start, end time.Time, interval time.Duration, each func(time.Time))
- func Compare(t1, t2 time.Time) int
- func DaysInMonth(t time.Time) int
- func RollMonth(t time.Time, months int) time.Time
- func TMax(t, u time.Time) time.Time
- func TMin(t, u time.Time) time.Time
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Between ¶
Between returns a slice of Times between the given start and end at each interval. start and end are inclusive. If end is before start, nil is returned. If end is earlier than an interval from start, a slice containing only start is returned.
Example ¶
sta, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
end, _ := time.Parse(time.RFC3339, "2006-01-02T15:05:05Z")
bt := kronos.Between(sta, end, 28*time.Second)
fmt.Println("Len:", len(bt))
for _, t := range bt {
fmt.Println(t.Format("15:04:05"))
}
Output: Len: 3 15:04:05 15:04:33 15:05:01
func BetweenDates ¶
BetweenDates returns a slice of Times between the given start and end dates, adding the given years/months/days between each iteration. start and end are inclusive. If end is before start, nil is returned. If end is earlier than an interval after start, a slice containing only start is returned.
Example ¶
start, _ := time.Parse("2006-01-02", "2012-11-22")
end, _ := time.Parse("2006-01-02", "2015-03-06")
bt := kronos.BetweenDates(start, end, 1, 0, 0)
fmt.Println("Len:", len(bt))
for _, t := range bt {
fmt.Println(t.Format("2006-01-02"))
}
Output: Len: 3 2012-11-22 2013-11-22 2014-11-22
func BetweenDatesEach ¶
BetweenDatesEach calls each for every time between start and end. See BetweenDates for more information.
func BetweenEach ¶
BetweenEach calls each for every time between start and end. See Between for more information.
func DaysInMonth ¶
DaysInMonth returns the number of days in the month of t.
Types ¶
This section is empty.