views:

157

answers:

4

Does anyone know of a DSL for time calculations, something that would be able to understand concepts like "2nd business day after the last business day of the month"?

I don't mind writing the parser, but I need help with the language itself.

+1  A: 

The canonical source on all this kind of stuff is Calendrical Calculations by Nachum Dershowitz and Ed Reingold. First it was the most-requested SP&E paper of all time; then it was a book; now it's in its third edition. At one time you could download Lisp code, but that feature seems to be gone from the web page. There is also an applet, and it is easy to reimplement; I have done implementations in Icon and in Lua.

So I'm suggesting what you really want is their library, and then if you want to have a parser for it, you know how to do that.

Norman Ramsey
http://emr.cs.iit.edu/~reingold/calendar.l
Svante
A: 

This may not be what you're looking for, but you might want to take a look at Chronic, a Ruby library for doing something like this:

http://chronic.rubyforge.org/

Paul Mrozowski
A: 

Have a look at the "Dynamic Holiday Date Calculator" by Jay Muntz.

It is a different use case, but unless you are turned off by everything XML, the same type of representation language could be used in your case. I found it easy to work with for defining custom calendars.

Peter Stuer
A: 

For Java, Joda time is really sleek!

elhoim