From 61cb5f22863e1d6df9fc78c0ab9b35f6ee00d7a2 Mon Sep 17 00:00:00 2001 From: Scott Lee Davis Date: Tue, 30 Apr 2019 23:43:13 -0700 Subject: [PATCH] offset current day hour+minute in every day recurring occurrence --- server/occurrence.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/server/occurrence.go b/server/occurrence.go index 2738c4d..114af0f 100755 --- a/server/occurrence.go +++ b/server/occurrence.go @@ -937,10 +937,8 @@ func (p *Plugin) everyEN(when string, user *model.User) (times []time.Time, err switch dateUnit { case T("day"): - d := 1 - if everyOther { - d = 2 - } + + day := 0 timeUnitSplit := strings.Split(timeUnit, ":") hr, _ := strconv.Atoi(timeUnitSplit[0]) @@ -960,7 +958,22 @@ func (p *Plugin) everyEN(when string, user *model.User) (times []time.Time, err return []time.Time{}, pErr } - nextDay := time.Now().In(location).AddDate(0, 0, d) + todayTime := time.Now().In(location) + if wallClock.Hour() >= todayTime.Hour() && wallClock.Minute() > todayTime.Minute() { + if everyOther { + day = 1 + } else { + day = 0 + } + } else { + if everyOther { + day = 2 + } else { + day = 1 + } + } + + nextDay := time.Now().In(location).AddDate(0, 0, day) occurrence := wallClock.In(location).AddDate(nextDay.Year(), int(nextDay.Month())-1, nextDay.Day()-1) times = append(times, p.chooseClosest(user, &occurrence, false).UTC())