BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlt::CalendarUtil Struct Reference

#include <bdlt_calendarutil.h>

Public Types

enum  ShiftConvention {
  e_UNADJUSTED , e_FOLLOWING , e_PRECEDING , e_MODIFIED_FOLLOWING ,
  e_MODIFIED_PRECEDING
}
 Enumeration used to delineate various date-shifting conventions. More...
 

Static Public Member Functions

static int addBusinessDaysIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar, int numBusinessDays)
 
static int nthBusinessDayOfMonthOrMaxIfValid (bdlt::Date *result, const bdlt::Calendar &calendar, int year, int month, int n)
 
static int shiftFollowingIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar)
 
static int shiftIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar, ShiftConvention convention)
 
static int shiftIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar, ShiftConvention convention, bdlt::DayOfWeek::Enum specialDay, bool extendSpecialDay, ShiftConvention specialConvention)
 
static int shiftModifiedFollowingIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar)
 
static int shiftModifiedPrecedingIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar)
 
static int shiftPrecedingIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar)
 
static int subtractBusinessDaysIfValid (bdlt::Date *result, const bdlt::Date &original, const bdlt::Calendar &calendar, int numBusinessDays)
 

Detailed Description

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

Member Enumeration Documentation

◆ ShiftConvention

Enumerator
e_UNADJUSTED 
e_FOLLOWING 
e_PRECEDING 
e_MODIFIED_FOLLOWING 
e_MODIFIED_PRECEDING 

Member Function Documentation

◆ addBusinessDaysIfValid()

static int bdlt::CalendarUtil::addBusinessDaysIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar,
int  numBusinessDays 
)
static

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()

static int bdlt::CalendarUtil::nthBusinessDayOfMonthOrMaxIfValid ( bdlt::Date result,
const bdlt::Calendar calendar,
int  year,
int  month,
int  n 
)
static

Load, into the specified result, the date corresponding to the specified nth 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()

int bdlt::CalendarUtil::shiftFollowingIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar 
)
inlinestatic

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() [1/2]

static int bdlt::CalendarUtil::shiftIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar,
ShiftConvention  convention 
)
static

Load, into the specified result, the date of the business day that is derived from the specified original date based on the specified calendar according to the specified date-shifting convention. Return 0 on success, and a non-zero value, without modifying *result, if a valid business date cannot be found according to the convention within the valid range of calendar.

◆ shiftIfValid() [2/2]

static int bdlt::CalendarUtil::shiftIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar,
ShiftConvention  convention,
bdlt::DayOfWeek::Enum  specialDay,
bool  extendSpecialDay,
ShiftConvention  specialConvention 
)
static

Load, into the specified result, the date of the business day that is derived from the specified original date based on the specified calendar according to the specified date-shifting convention, except when the original is either the specified specialDay of the week, or - if the specified extendSpecialDay is true - one of the (possibly empty) set of contiguous non-business days immediately preceding a specialDay according to the calendar, in which case the result is determined using the specified specialConvention. Return 0 on success, and a non-zero value, without modifying *result, if a valid business date cannot be found according to the above algorithm within the valid range of calendar. Note that this method is useful for computing, for example, Korean bond coupon payment dates.

◆ shiftModifiedFollowingIfValid()

static int bdlt::CalendarUtil::shiftModifiedFollowingIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar 
)
static

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()

static int bdlt::CalendarUtil::shiftModifiedPrecedingIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar 
)
static

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()

int bdlt::CalendarUtil::shiftPrecedingIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar 
)
inlinestatic

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()

static int bdlt::CalendarUtil::subtractBusinessDaysIfValid ( bdlt::Date result,
const bdlt::Date original,
const bdlt::Calendar calendar,
int  numBusinessDays 
)
static

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).


The documentation for this struct was generated from the following file: