Пример #1
0
// EachSunset returns the sunsets for a given latitude and longitude.
// lat is the latitude where north is positive and south is negative.
// lon is the longitude where east is positive and west is negative.
func EachSunset(lat, lon float64) tasks_recurring.R {
	return tasks_recurring.RFunc(func(t time.Time) functional.Stream {
		var s sunsetIterator
		s.Around(lat, lon, t)
		for !s.Sunset().After(t) {
			s.AddDays(1)
		}
		return &s
	})
}
Пример #2
0
// OnOrBefore ensures that the times in r happen on or before
// hour:min. If a time is after hour:min, it is moved earlier to be
// hour:min. If a time is 12 hours or more after hour:min, then it is
// considered to be before hour:min on the next day, and no adjustment is
// made.
func OnOrBefore(r tasks_recurring.R, hour, min int) tasks_recurring.R {
	return tasks_recurring.RFunc(func(t time.Time) functional.Stream {
		s := r.ForTime(t)
		return functional.DropWhile(
			functional.NewFilterer(func(ptr interface{}) error {
				p := ptr.(*time.Time)
				if p.After(t) {
					return functional.Skipped
				}
				return nil
			}),
			&happensBefore{
				Stream: s, hour: hour, min: min, hm: toHourMinute(hour, min)})
	})
}