Recurring date is showing wrong next date

I’m trying to set up a recurring date as follows:

[date=2021-01-24 time=08:30:00 timezone="America/New_York" recurring="1.weeks"]

Since this date is in the future, it should show January 24, 2021 as the next occurrence. Instead, it’s showing February 28, 2021.

Actual date:
2021-01-24T13:30:00Z

Screenshot from post preview (in case the preview shows it differently):
image


Changing the date to 2021-01-25 jumps the date all the way to March 8, 2021, skipping 8 days instead of 1 day. Every 7th day it jumps an extra week, which seems to be why the date is so off. Am I doing something wrong here? Maybe there’s an edge case with creating recurring dates that are in the future in general or in a future year specifically.

2 Likes

This seems oddly intentional from the code. It always seems to base the recurring date off the different between the current date and today:

https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/assets/javascripts/lib/local-date-builder.js.es6#L55

I tried changing this in the code to be localDate.datetime and the output was correct in the browser but 4 tests failed. It seemed they were ensuring it works this way, so now I’m wondering if I’m missing something @joffreyjaffeux? Recurring should be after the date you entered not the current date right?

4 Likes

Yes indeed I think I have overlooked this case and mostly took into consideration when you try to create a date in past and recurring will make it happen in future. Will have a look next week.

7 Likes

This is awaiting review, but that should fix it once merged:

https://github.com/discourse/discourse/pull/11587

Thanks for the report, I’m happy to have this bug out of the way.

7 Likes