From: Jeff Garland (jeff_at_[hidden])
Date: 2004-04-19 19:10:09
On Mon, 19 Apr 2004 19:14:12 -0400, Hurd, Matthew wrote
> Some further quick thoughts from my dark past...
> Most places I've been, typically finance related, have had dates,
> date expressions, date generators and calendars as concepts.
> Date expressions give you the concept of the last day of the month.
> They can give you the third Wednesday of the month. I'm used to just
> strings like: 3wed+2b (3rd Wednesday + 2 business days), -1Sun+1b (Last
> Sunday + next business day), -1d (last day of the month). Strikes me
> that date expressions would look nice as expression templates.
Sure but the real requirement is that they be strings because these things get
read in from databases and files in real apps -- they don't tend to be
hardcoded in code.
> Extend this with date generators that can generate such dates for month
> patterns (every 3 months, explict months) within the context of a
Yep. It is essentially a partial projection of a time period that allows for
the calculation of a complex rule. Happens all the time in various sorts of
> Calendars with holidays and being able to combine them for transactions
> is important. You can then refer to the second business day after
> the third Wednesday and such things. A typical use of a calendar is
> to have calendars for business jurisdictions and be able to union
> them. The usual implementation I've used is a bit field of days of
Interesting. Sounds like a good application for dynamic_bitset :-)
> the year for however many years, though a holiday list and look up
> might make more sense. A default "Western" calendar only has Sat,
> Sun as non-business days.
There is a simplistic example in the library that shows the later approach,
but it doesn't get into dealing with business days. Of course if someone
wants to write some additional date generators for business days I can put
them into the library ;-)
> Date expressions can get interesting when you're trying to represent
> various business rules, e.g. -Sun+2b unless it is less than 3 days
> before the end of the month then it is -Sun-1b, which can lead you down
> the path of extending the syntax to include comparisons, conditional
> representation and the notion of "instance". E.g (-sun+2b) <= -3d ?
> (-sun+2b) : (-sun-1b). Now that's fun :-)
> Once place I worked had easter, the lunar calendar and the like to do
> some further unusual stuff.
> Adding something to a date could be a date expression:
> 1. date_add( date(2004,2,29), "+3M : -d") // 31 May 2004
> 2. date_add( date(2004,2,29), "+1M : -0b") // 29th Mar if
> a business day, previous b day if not one
> Hmmm, I forget how that bit used to work, but you get the idea...
> Generate a date or dates from some specification, the last day of the
> month is a simple specification.
Which is why I'm starting to see all these logical constructs as just another
form of date generation type that has a set of rules and combines 2 elements
(a date and month count in this case) to get another date.
Thx -- I always like to hear about all the wild requirements from this crazy