The script is running in the browser, and the specific problem I’m facing is with a calendar that consists of 7 days
Let’s say I extract 7 days from a Date object by doing something like today, today + 1, today + 2, and so on until I get all 7 days
The problem is that the dates inside the calendar keep updating daily. Imagine I initially have Dec 2 to Dec 8. When tomorrow comes, it changes to Dec 3 to Dec 9
What I actually want is to keep those original 7 days in the calendar without changing them daily. Once the 7-day period is over, I’ll grab another 7 days using the current date and repeat the same process.
Got it, sounds like local storage is what you're looking for.
Essentially, when you start your application, you'd check if there's a date stored in local storage. If there is, check if a week has passed since that date, and update it if so.
View all comments
Show parent comment
2
u/r2idw 2d ago
The script is running in the browser, and the specific problem I’m facing is with a calendar that consists of 7 days
Let’s say I extract 7 days from a Date object by doing something like today, today + 1, today + 2, and so on until I get all 7 days
The problem is that the dates inside the calendar keep updating daily. Imagine I initially have Dec 2 to Dec 8. When tomorrow comes, it changes to Dec 3 to Dec 9
What I actually want is to keep those original 7 days in the calendar without changing them daily. Once the 7-day period is over, I’ll grab another 7 days using the current date and repeat the same process.