I’m trying to re-write a backend interface doohickey for a calendar, a todo list and another sort of calendar and found that they all were programmed to have subtly different formats for patterns of dates that could be used to configure certain properties in them.
I have three screens that have different ways of essentially doing the same thing:
and they essentially have the same information. I’ve got objects for all these, but what I’d like to do is serialize the objects, not to bytecode, but to a semi-human readable format that could be transferred between not only these three screens, but stored as one field in a database and XML.
7
Probably the closest thing to a standard would be the recurrence rules of the iCalendar format, specified in RFC 2445. Nearly every reputable calendar-related program can import and export iCal format, although they vary a lot in how thoroughly they support recurrence rules. You should be able to find an open source project with a parser. Whether you consider it “abbreviated” or not is a matter of perspective, I suppose. It could certainly be shorter, but it beats listing the dates individually.
1
You should be able to use Cron notation for this. It originated for scheduling jobs within Unix, but there are now many libraries for different languages to convert to and from it.
Essentially, Cron stores date/time intervals in 5 (text) columns representing Years, Months, Days, Hours and Minutes.
Using a combination of * (meaning every day, hour minute etc), numbers representing repetitions and special characters to represent more specialized scenarios you should be able to store any kind of date information.
More: http://en.wikipedia.org/wiki/Cron
1