dateconv.h File Reference

#include "cgeneral.h"
#include "cdate.h"
#include "mdydate.h"

Defines

#define JPMCDS_SUNDAY   0
#define JPMCDS_MONDAY   1
#define JPMCDS_TUESDAY   2
#define JPMCDS_WEDNESDAY   3
#define JPMCDS_THURSDAY   4
#define JPMCDS_FRIDAY   5
#define JPMCDS_SATURDAY   6
#define JPMCDS_TDATE_BASE_YEAR   1601
#define JPMCDS_IS_LEAP(year)

Functions

TDate JpmcdsDate (long year, long month, long day)
 Converts year, month, day to a date and returns the date.
int JpmcdsDateToMDY (TDate date, TMonthDayYear *mdyDate)
 Converts TDate to Month, Day, Year.
int JpmcdsMDYToDate (TMonthDayYear *mdyDate, TDate *date)
 Converts Month, Day, Year to TDate.
int JpmcdsDayOfWeek (TDate date, long *dayOfWeek)
 Converts TDate to day of week (0-6).
int JpmcdsNormalizeMDY (TMonthDayYear *mdy)
 Normalizes a month/day/year.
int JpmcdsDaysInMonth (long year, long month)
 Returns # days in month.
int JpmcdsDateToEOM (TDate inDate, TDate *outDate)
 Moves a date to the end of the current month.

Detailed Description


Define Documentation

#define JPMCDS_IS_LEAP ( year   ) 

Value:

(                                              \
                            (((year)%4 == 0) && ((year)%100 != 0)) || \
                            ((year)%400 == 0)                            \
                          )


Function Documentation

TDate JpmcdsDate ( long  year,
long  month,
long  day 
)

Converts year, month, day to a date and returns the date.

This is useful for initializing dates within test routines. Returns FAILURE for invalid dates.

int JpmcdsDateToMDY ( TDate  date,
TMonthDayYear *  mdyDate 
)

Converts TDate to Month, Day, Year.

NOTE: routine was written to avoid divides especially as well as multiplies. Whenever possible, the type int is used-which is presumably the fastest type on a given architecture.

int JpmcdsDayOfWeek ( TDate  date,
long *  dayOfWeek 
)

Converts TDate to day of week (0-6).

0 is Sunday, 1 is Monday.... 6 is Saturday

int JpmcdsMDYToDate ( TMonthDayYear *  mdyDate,
TDate date 
)

Converts Month, Day, Year to TDate.

NOTE: routine was written to avoid divides (especially) and multiplies.

int JpmcdsNormalizeMDY ( TMonthDayYear *  mdy  ) 

Normalizes a month/day/year.

If month is out of range, it is brought into range, and the years are incremented or decremented as appropriate. If day belongs to a month/year combination which does not exist, (such as April 31) the day is reduced so that it becomes valid.(to April 30).


Distributed by BN Algorithms Ltd -- consulting in quantitative finance, mathematical algorithms and software implementations. CDS Home Page. For enquires contact webs@bnikolic.co.uk.
This documentation is derived from ISDA CDS Standard Model version 1.7. You can get a copy of the original ISDA code at www.bnikolic.co.uk. This is a derivative work under the terms of the ISDA CDS Standard Model Public License. BN Algorithms Ltd licenses this work to you solely for on-screen viewing on your own computer. Making copies and further distribution of this work is prohibited.
This documentation is provided "as-is", without warranty of any kind, either expressed or implied, including, without limitation, warranties that the documentation is free of defects, merchantable, fit for a particular purpose or non-infringing. the entire risk as to the quality of the documentation is with you. Should this documentation prove defective in any respect, you (not the licensor) assume the cost of any necessary correction. This disclaimer of warranty constitutes an essential part of this license.