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

Remind me Today -> Starts tomorrow #176

Closed
Fmyschkin opened this issue Feb 20, 2020 · 4 comments
Closed

Remind me Today -> Starts tomorrow #176

Fmyschkin opened this issue Feb 20, 2020 · 4 comments
Labels
Help Wanted Community help wanted Type/Bug Something isn't working
Milestone

Comments

@Fmyschkin
Copy link

Summary

/remind me test today -> schedules reminder for tomorrow
/remind me test at 18:00 -> schedules reminder for tomorrow
/remind me test at 18:00 today -> schedules reminder for tomorrow

Steps to reproduce

Steps to reproduce the behavior:

  1. /remind me test today

  2. Reminder is set tomorrow 9am

  3. /remind me test at 18:00 (Current Time 15:00)

  4. Reminder is set tomorrow 6pm

  5. /remind me test at 18:00 today (Current Time 15:11)

  6. Reminder is set tomorrow 6pm

Expected behavior

Reminder should be set to today

Server configuration

Operating system:
Linux Ubuntu

Mattermost version:
5.18.1

Remind version:
0.4.4
remindbot_bug

Additional context

Experimental timezone support is enabled.

@piotr-wegert
Copy link

Happens to us as well.

@scottleedavis scottleedavis added the Type/Bug Something isn't working label May 2, 2020
@scottleedavis scottleedavis added the Help Wanted Community help wanted label May 10, 2020
@scottleedavis scottleedavis modified the milestones: 0.5.0, 0.4.6 May 10, 2020
@YuKitAs
Copy link
Contributor

YuKitAs commented May 24, 2020

It also has been happening to me for a while, whenever I tried to set a reminder later than 14:00 in CEST.
After digging into the code, I think the issue lies with the rounding

t, pErr := time.ParseInLocation(time.Kitchen, strings.ToUpper(normalizedWhen), location)
now := time.Now().In(location).Round(time.Hour * time.Duration(24))
occurrence := t.AddDate(now.Year(), int(now.Month())-1, now.Day()-1)

If now is later than 12:00 in UTC, it will be rounded up to the next day, and the calculation for the occurrence will be incorrect. For example:

now: 2020-05-24 15:10:17.815540836 +0200 CEST
rounded now: 2020-05-25 02:00:00 +0200 CEST

In this case the occurrence should be t.AddDate(now.Year(), int(now.Month())-1, now.Day()-2) imho.

Round():

// Round returns the result of rounding t to the nearest multiple of d (since the zero time).
// The rounding behavior for halfway values is to round up.
// If d <= 0, Round returns t stripped of any monotonic clock reading but otherwise unchanged.
//
// Round operates on the time as an absolute duration since the
// zero time; it does not operate on the presentation form of the
// time. Thus, Round(Hour) may return a time with a non-zero
// minute, depending on the time's Location.
func (t Time) Round(d Duration) Time {
	t.stripMono()
	if d <= 0 {
		return t
	}
	_, r := div(t, d)
	if lessThanHalf(r, d) {
		return t.Add(-r)
	}
	return t.Add(d - r)
}

@lucaswerkmeister
Copy link

Since it hasn’t been mentioned here yet, a workaround is to explicitly mention today’s date:

/remind me test on 16.11.2020 at 18:00

@scottleedavis
Copy link
Owner

Fixed occurence calculation #193

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Help Wanted Community help wanted Type/Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants