Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
offset current day hour+minute in every day recurring occurrence
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleedavis committed May 1, 2019
1 parent aee5e20 commit 61cb5f2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions server/occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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())

Expand Down

0 comments on commit 61cb5f2

Please sign in to comment.