Component of the Week #23: bdlt_calendar

Summary:
  • A fast repository for accessing weekend and holiday information.

The bdlt::Calendar class provides a very specialized database that provides fast access to certain information on a range of dates. This functionality is tailored to answer questions relevant for certain business functions, such as computing settlement dates.

Note that the calendar is simply a repository of information set by the user, the information itself must be obtained from other sources.

Each calendar object covers a user-supplied range of dates. By default, each of those dates is classified as a “business day” unless the user sets them otherwise. There are two categories that can be used to classify a day as “not a business day”. A date can be be set as a “weekend” day or a “holiday”.

  1. Weekend days are non-business days by virtue of their day-of-week value (e.g., Friday, Saturday, Sunday).

  2. Holidays are non-business days in the calendar range that are explicitly set one at a time. Optionally, holidays can be tagged with some additional descriptive information.

Once the calendar object has been initialized, the isBusinessDay accessor method returns a true/false value in constant time for any date in the object’s range.

There is a rich set of methods to define the calendar object’s contents and access its information. There are also an methods that combine information – either an intersection or union – from other calendars, a facility that is useful in solving certain problems. For example, seeing the common set of settlement dates between a US and Japanese settlement calendar.

For more details, see: