This struct provides a namespace for utility functions that operate on dates in the context of supplied calendars.

Synopsis

Declared in <bdlt_calendarutil.h>

struct CalendarUtil;

Enums

Name

Description

ShiftConvention

Enumeration used to delineate various date‐shifting conventions.

Static Member Functions

Name

Description

addBusinessDaysIfValid

Load, into the specified result, the date that is the specified numBusinessDays chronologically after the specified original date according to the specified calendar. The resulting date is chronologically before the original date for negative values of numBusinessDays, the chronologically earliest business day that is on or after the original date for 0 == numBusinessDays, and chronologically after the original date for positive values of numBusinessDays. Return 0 on success, and a non‐zero value, without modifying *result, if either the original date or the resulting date is not within the valid range of calendar. Note that if 0 != numBusinessDays, then the result of addBusinessDaysIfValid(res, orig, cal, numBusinessDays) is identical to the result of subtractBusinessDaysIfValid(res, orig, cal, ‐numBusinessDays).

nthBusinessDayOfMonthOrMaxIfValid

Load, into the specified result, the date corresponding to the specified n`th business day of the specified `month and the specified year based on the specified calendar. A positive value of n indicates that counting the number of business days begins from the first calendar date of the month (inclusive), and a negative value of n indicates that counting the number of business days begins from the last calendar date of the month (inclusive). If there are fewer than abs(n) business days in the month according to the calendar, the business day furthest from the first date of the month is chosen if n > 0, and the business day furthest from the last date of the month is chosen if n < 0. Return 0 on success, and a non‐zero value, without modifying *result, if the entire month specified by year and month is not within the valid range of the calendar or there are no business days in the month specified by year and month. The behavior is undefined unless n != 0, 1 <= year <= 9999, and 1 <= month <= 12.

shiftFollowingIfValid

Load, into the specified result, the date of the chronologically earliest business day that is on or after the specified original date based on the specified calendar. Return 0 on success, and a non‐zero value, without modifying *result, if the original date is not within the valid range of calendar or the following business day cannot be found within the valid range of calendar.

shiftIfValid

shiftIfValid overloads

shiftModifiedFollowingIfValid

Load, into the specified result, the date of the chronologically earliest business day that is on or after the specified original date, unless a date cannot be found in the same month, in which case load the chronologically latest business day before the original date based on the specified calendar. Return 0 on success, and a non‐zero value, without modifying *result, if the original date is not within the valid range of calendar or a valid business date cannot be found according to the above algorithm within the valid range of calendar.

shiftModifiedPrecedingIfValid

Load, into the specified result, the date of the chronologically latest business day that is on or before the specified original date, unless a date cannot be found in the same month, in which case load the chronologically earliest business day after the original date based on the specified calendar. Return 0 on success, and a non‐zero value, without modifying *result, if the original date is not within the valid range of calendar or a valid business date cannot be found according to the above algorithm within the valid range of calendar.

shiftPrecedingIfValid

Load, into the specified result, the date of the chronologically latest business day that is on or before the specified original date based on the specified calendar. Return 0 on success, and a non‐zero value, without modifying *result, if the original date is not within the valid range of calendar or the preceding business day cannot be found within the valid range of calendar.

subtractBusinessDaysIfValid

Load, into the specified result, the date that is the specified numBusinessDays chronologically before the specified original date according to the specified calendar. The resulting date is chronologically before the original date for positive values of numBusinessDays, the chronologically latest business day that is on or before the original date for 0 == numBusinessDays, and chronologically after the original date for negative values of numBusinessDays. Return 0 on success, and a non‐zero value, without modifying *result, if either the original date or the resulting date is not within the valid range of calendar. Note that if 0 != numBusinessDays, then the result of subtractBusinessDaysIfValid(res, orig, cal, numBusinessDays) is identical to the result of addBusinessDaysIfValid(res, orig, cal, ‐numBusinessDays).

Created with MrDocs