#include "cgeneral.h"
#include "cdate.h"
Functions | |
int | JpmcdsMakeTDateArray (TDate baseDate, TDateInterval *interval, int startIdx, int arrayIncrement, int ndates, TDate *dateArray) |
Make an array of TDates. | |
int | JpmcdsCountDates (TDate fromDate, TDate toDate, TDateInterval *interval, int *numIntervals, int *extraDays) |
Counts # TDateIntervals in a range of dates. | |
int | JpmcdsFreq2TDateInterval (long freq, TDateInterval *interval) |
Converts a frequency (# times/year) to a TDateInterval. | |
int | JpmcdsDateIntervalToFreq (TDateInterval *interval, double *freq) |
Converts a TDateInterval to a frequency. | |
int | JpmcdsDateIntervalToYears (TDateInterval *interval, double *years) |
Converts a TDateInterval to # years. | |
int | JpmcdsDateFromDateAndOffset (TDate oldDate, TDateInterval *interval, int index, TDate *newDate) |
Calculates a date from another date and offset represented by interval and index. |
int JpmcdsCountDates | ( | TDate | fromDate, | |
TDate | toDate, | |||
TDateInterval * | interval, | |||
int * | numIntervals, | |||
int * | extraDays | |||
) |
Counts # TDateIntervals in a range of dates.
Note that fromDate can be either later than or earlier than toDate.
In order to make this routine speedier we start from a low estimate of result value that is calculated using division (speedy approach). Based on the low estimate we calculate the results.
Note that we allways calculate currDate based on fromDate rather than lastDate. We MUST do it because date + (n*Interval) = ((date + Interval)+Interval) ... )+Interval is not always true
int JpmcdsDateFromDateAndOffset | ( | TDate | oldDate, | |
TDateInterval * | interval, | |||
int | index, | |||
TDate * | newDate | |||
) |
Calculates a date from another date and offset represented by interval and index.
newDate = oldDate + index*interval
int JpmcdsDateIntervalToFreq | ( | TDateInterval * | interval, | |
double * | freq | |||
) |
int JpmcdsDateIntervalToYears | ( | TDateInterval * | interval, | |
double * | years | |||
) |
Converts a TDateInterval to # years.
Note that if the TDateInterval is a month type (A,S,Q), the routine uses 30/360 to compute the year fraction. If it is a day type (D,W), it uses Act/365F.
int JpmcdsFreq2TDateInterval | ( | long | freq, | |
TDateInterval * | interval | |||
) |
Converts a frequency (# times/year) to a TDateInterval.
Returns SUCCESS/FAILURE.
int JpmcdsMakeTDateArray | ( | TDate | baseDate, | |
TDateInterval * | interval, | |||
int | startIdx, | |||
int | arrayIncrement, | |||
int | ndates, | |||
TDate * | dateArray | |||
) |
Make an array of TDates.
Returns SUCCESS/FAILURE.