Is there an algorithm for weekly reminders ?
For example, I set a reminder for Thursday & I check the “weekly” option.
The Reminder is supposed to alert every Thursday then,but how is this done?
I thought about an idea, but I guess it’s very stupid:
- Get today’s “day”.
- Get today’s “date”.
- Get the wanted day number.
- Subtract both days from each other.
- using [4] get that day’s date.
- Increment the counter after every alert with 7.
I don’t even know whether this will work or not, I’m sure there is a better way to do it, so I need your opinions before starting implementation.
PS: I use JavaScript so the functions are very limited.
It’s not entirely clear what you’re trying to do.
If your code needs to know whether it’s Thursday, that’s really easy using
getDay, which gives you the day of the week:The day numbers start with
0= Sunday.If your code needs to find the next Thursday starting on a given date:
or of course without the loop:
If you have a Thursday already and you need to know the date for the next Thursday: