RE: [boost] date-generators (was Date-Time)

On Behalf Of Jeff Garland Subject: Re: [boost] date-generators (was Date-Time)
On Mon, 19 Apr 2004 14:22:53 -0400 (EDT), Rob Stewart wrote
That does make sense, but so does the "date wrapper" idea. The latter provides a convenient means to use operator overloading meaningfully while making the behavior of those operators specific to the wrapper type. I think the date wrapper approach will prove easier to use, but more cumbersome to implement.
I have no idea what the 'date wrapper approach' is...
Jeff
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. Extend this with date generators that can generate such dates for month patterns (every 3 months, explict months) within the context of a calendar. 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 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. 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. $0.005 Matt Hurd. IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

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.
Ok :-)
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 calendar.
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 'scheduling' applications.
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 :-)
Yikes....
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 domain... Jeff

On Mon, 19 Apr 2004 19:14:12 -0400, Hurd, Matthew wrote
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 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.
Totally agree with that, business related apps need holidays and business days. But holidays determination should be easily localizable.
representation and the notion of "instance". E.g (-sun+2b) <= -3d ? (-sun+2b) : (-sun-1b). Now that's fun :-)
Not that much. But what about : (christmas+1b)
Once place I worked had easter, the lunar calendar and the like to do some further unusual stuff.
Here in France we have the following date concepts (at least the ones I am aware of) : - Jours ouvrés (days with active buisness) = business days - Jours ouvrables (days where you may have active business). Depends on business type, usually monday-friday, tuesday-saturday or monday-saturday. - Decades (multiple of ten days): For example, you can have a due date expressed as : 25 jours fin décade (25 days then end of decade) then for 1st-5th january, the due date is 30th january, 6-15th jan=>10th feb, 16th-25th jan=>20th and 25th jan-5thfeb => 28th feb (29th if leap year) - Mois de 30 jours (30 days month) : Number of days converted in months => 90 days mean 3 months. I bet this one is more usual. Cyrille Dupuydauby

On Tue, 20 Apr 2004 10:07:58 +0200, Cyrille Dupuydauby wrote
Totally agree with that, business related apps need holidays and business days. But holidays determination should be easily localizable.
It isn't just by locale, the application needs to determine holidays. For example, while there are some holidays in the US that everyone agrees on, but lots of companies use a couple floating holidays every year. They typically will tack one say a Friday after a July 4th on a Thursday to give employees a 4 day weekend. So any calculation of business days needs to be capable of handling these application specific cases.
Here in France we have the following date concepts (at least the ones I am aware of) : - Jours ouvrés (days with active buisness) = business days - Jours ouvrables (days where you may have active business). Depends on business type, usually monday-friday, tuesday-saturday or monday-saturday. - Decades (multiple of ten days) : For example, you can have a due date expressed as : 25 jours fin décade (25 days then end of decade) then for 1st-5th january, the due date is 30th january, 6- 15th jan=>10th feb, 16th-25th jan=>20th and 25th jan-5thfeb => 28th feb (29th if leap year) - Mois de 30 jours (30 days month) : Number of days converted in months => 90 days mean 3 months. I bet this one is more usual.
Interesting.... Jeff
participants (3)
-
Cyrille Dupuydauby
-
Hurd, Matthew
-
Jeff Garland