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:

  1. Calendar
  2. Scheduler
  3. Todo

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.

  • 2
    Those patterns are business requirements, not standards. They arise from meetings which take place weekly, follow-ups which take place monthly, and mortgage payments, which often take place monthly, but can also take place bi-weekly. The Xth day of Y is how many holidays are officially defined. – Robert Harvey Dec 16 '13 at 19:52
  • 1
    @RobertHarvey I mean standards for storing that information outside of serialized objects. I'll edit the question. – Peter Turner Dec 16 '13 at 19:56
  • Related (obviously not exactly): msmvps.com/blogs/jon_skeet/archive/2009/11/02/… – JDB still remembers Monica Dec 16 '13 at 20:10
  • 2
    en.wikipedia.org/wiki/Cron ? – razethestray Dec 16 '13 at 20:14
  • 3
    ISO 8601? It has all the standard time things, durations, and repeating periods. – user40980 Dec 16 '13 at 20:37

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.

| improve this answer | |
  • Thanks for this, if you added some examples, I'd find this to be a very complete answer, not sure why the questions was closed it's got a fairly straightforward answer (although the cron idea probably would work too, this is more helpful because of exchange interoperability), I just couldn't think of the wording for the question when I was looking it up on Google so the word "abbreviated" got in there. – Peter Turner Dec 27 '13 at 13:39

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

| improve this answer | |
  • Cron fields are: Day Of Week, Month of Year, Day of Month Hour, Min. You've confused the "Years" and "Day of Week". The noon of third friday of the month would be: 0 12 * 20-26 5 which is: Min H Mon DoM DoW so the 0th min of the 12th hour of every month where the day of week is 5 and the day of month is between 20 and 26. – user40980 Dec 16 '13 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.