0

I'm just wondering if anyone can point me in the right direction.

I have an array of events

var event = [
    'Event1',
    'Event2',
    'Event3'
]

As well as a start_date

start_date = '11/10/17'

My goal is to take the current date and find the weekly recurring event for the next few weeks. For example, based on a start_date of 11/10/17 and 3 events, the schedule events would be:

 11/10/17 - Event 1
 11/17/17 - Event 2
 11/24/17 - Event 3
 12/1/17 - Event 1
 12/8/17 - Event 2
 .
 .

Let's say it is currently 12/6/17 and I want to display the schedule for the next few weeks my script should output

 12/8/17 - Event 2
 12/15/17 - Event 3
 12/22/17 - Event 1

I figure I would have to take the current date, find the next Friday (since events occur every Friday) as determined by getting the day of startDate, then somehow do some mod math to figure out what event comes next.

This problem is stumping me. Any assistance?

SquidZ00
  • 1
  • 1
  • Unsure of the context behind this question, but why are your events and event dates stored separately? Could you not store an array of event objects, containing the title 'Event1', and the start date? – Lee Brindley Nov 10 '17 at 14:02
  • Because I simply have "Event 1" as the 0th event, "Event 1", as the 1th event, and "Event 3" as the 2nd event. The goal is the script is to perfrom the required mod math around the "event clock" to determine the date. The event dates are never stored, only an initial seeding date for the first occurrence of the 0th event. The calendar is dynamically generated by running mod math against the start date. – SquidZ00 Nov 10 '17 at 14:11
  • @LeeBrindley See above – SquidZ00 Nov 10 '17 at 14:15

0 Answers0