5

Is there a good way of representing complex schedules as a string? Failing that, is there a standard way of representing schedules as JSON?

Are there any relevant standards I should know about?

Examples of schedules (all times in utc):

  • Every Monday, Tuesday and Thursday at 17:00
  • Monthly on the 5th of the month
  • First Monday of every month
  • Daily at 9:00 and 17:00
ddouglascarr
  • 1,334
  • 3
  • 14
  • 23
  • 2
    First invent a simple data structure to represent the schedule efficiently for all cases you're interested in, then map that to JSON. – Hot Licks Feb 18 '15 at 21:02
  • 2
    You may also wish to read this: http://stackoverflow.com/questions/1548031/data-structure-for-storing-recurring-events – Day Davis Waterbury Feb 18 '15 at 21:17
  • 1
    Hint: Look at a calendar tool like Google's calendar, start to schedule an event, and then select "Repeat" or whatever. Study the presentation you get for how to repeat. It won't cover everything but it may give you some ideas. (Google's cal is a pretty good example here, Outlook's sucks.) – Hot Licks Feb 18 '15 at 21:50

1 Answers1

4

The most relevant standard is probably iCalendar, as defined in RFC 5545. It long ago addressed the many, many, many challenges of representing schedule data. Unsurprisingly, an analogous JSON format also exists; also unsurprisingly, it's called jCal.

There are many libraries for dealing with iCal data, but not a lot for dealing with jCal. Mozilla's ical.js looks promising, although it's really poorly documented (a few examples exist in its wiki, at least). You may be better off just using iCal as your data format, since it's so widely supported.

Community
  • 1
  • 1
Jordan Running
  • 102,619
  • 17
  • 182
  • 182