LibreOffice Module scaddins (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
sca::analysis::ScaDate Class Reference

Helper class for date calculation for various financial functions. More...

#include <analysishelper.hxx>

Public Member Functions

 ScaDate ()
 
 ScaDate (sal_Int32 nNullDate, sal_Int32 nDate, sal_Int32 nBase)
 
 ScaDate (const ScaDate &rCopy)
 
ScaDateoperator= (const ScaDate &rCopy)
 
sal_uInt16 getMonth () const
 
sal_uInt16 getYear () const
 
void addMonths (sal_Int32 nMonthCount)
 adds/subtracts the given count of months, adjusts day More...
 
void setYear (sal_uInt16 nNewYear)
 sets the given year, adjusts day More...
 
void addYears (sal_Int32 nYearCount)
 adds/subtracts the given count of years, adjusts day More...
 
sal_Int32 getDate (sal_Int32 nNullDate) const
 
bool operator< (const ScaDate &rCmp) const
 
bool operator<= (const ScaDate &rCmp) const
 
bool operator> (const ScaDate &rCmp) const
 
bool operator>= (const ScaDate &rCmp) const
 

Static Public Member Functions

static sal_Int32 getDiff (const ScaDate &rFrom, const ScaDate &rTo)
 

Private Member Functions

void setDay ()
 is true, if the US method of 30-day-calculations is used. More...
 
sal_uInt16 getDaysInMonth () const
 
sal_uInt16 getDaysInMonth (sal_uInt16 _nMon) const
 
sal_Int32 getDaysInMonthRange (sal_uInt16 nFrom, sal_uInt16 nTo) const
 @ return count of days in the given month range More...
 
sal_Int32 getDaysInYearRange (sal_uInt16 nFrom, sal_uInt16 nTo) const
 @ return count of days in the given year range More...
 
void doAddYears (sal_Int32 nYearCount)
 Adds/subtracts the given count of years, does not adjust day. More...
 

Private Attributes

sal_uInt16 nOrigDay
 
sal_uInt16 nDay
 is the day of the original date. More...
 
sal_uInt16 nMonth
 is the calculated day depending on the current month/year. More...
 
sal_uInt16 nYear
 is the current month (one-based). More...
 
bool bLastDayMode: 1
 is the current year. More...
 
bool bLastDay: 1
 if true, recalculate nDay after every calculation. More...
 
bool b30Days: 1
 is true, if original date was the last day in month. More...
 
bool bUSMode: 1
 is true, if every month has 30 days in calculations. More...
 

Detailed Description

Helper class for date calculation for various financial functions.

Definition at line 726 of file analysishelper.hxx.

Constructor & Destructor Documentation

◆ ScaDate() [1/3]

sca::analysis::ScaDate::ScaDate ( )

Definition at line 2473 of file analysishelper.cxx.

◆ ScaDate() [2/3]

sca::analysis::ScaDate::ScaDate ( sal_Int32  nNullDate,
sal_Int32  nDate,
sal_Int32  nBase 
)
Parameters
nBasedate handling mode (days in month / days in year): 0 = 30 days / 360 days (US NASD) 1 = exact / exact 2 = exact / 360 3 = exact / 365 4 = 30 days / 360 days (Europe) 5 = exact / exact (no last day adjustment)

Definition at line 2485 of file analysishelper.cxx.

References b30Days, bLastDay, bLastDayMode, bUSMode, sca::analysis::DaysInMonth(), sca::analysis::DaysToDate(), nMonth, nOrigDay, nYear, and setDay().

◆ ScaDate() [3/3]

sca::analysis::ScaDate::ScaDate ( const ScaDate rCopy)

Definition at line 2495 of file analysishelper.cxx.

Member Function Documentation

◆ addMonths()

void sca::analysis::ScaDate::addMonths ( sal_Int32  nMonthCount)

adds/subtracts the given count of months, adjusts day

Exceptions
css::lang::IllegalArgumentException

Definition at line 2572 of file analysishelper.cxx.

References doAddYears(), nMonth, and setDay().

Referenced by sca::analysis::GetCoupdays(), AnalysisAddIn::getEdate(), sca::analysis::lcl_GetCoupncd(), and sca::analysis::lcl_GetCouppcd().

◆ addYears()

void sca::analysis::ScaDate::addYears ( sal_Int32  nYearCount)
inline

adds/subtracts the given count of years, adjusts day

Exceptions
css::lang::IllegalArgumentException

Definition at line 816 of file analysishelper.hxx.

References doAddYears(), and setDay().

Referenced by sca::analysis::lcl_GetCoupncd(), and sca::analysis::lcl_GetCouppcd().

◆ doAddYears()

void sca::analysis::ScaDate::doAddYears ( sal_Int32  nYearCount)
private

Adds/subtracts the given count of years, does not adjust day.

Exceptions
css::lang::IllegalArgumentException

Definition at line 2564 of file analysishelper.cxx.

References nYear.

Referenced by addMonths(), and addYears().

◆ getDate()

sal_Int32 sca::analysis::ScaDate::getDate ( sal_Int32  nNullDate) const
Returns
the internal number of the current date

Definition at line 2591 of file analysishelper.cxx.

References bLastDay, bLastDayMode, sca::analysis::DaysInMonth(), nMonth, nOrigDay, and nYear.

Referenced by sca::analysis::GetCoupncd(), sca::analysis::GetCouppcd(), and AnalysisAddIn::getEdate().

◆ getDaysInMonth() [1/2]

sal_uInt16 sca::analysis::ScaDate::getDaysInMonth ( ) const
inlineprivate
Returns
count of days in current month

Definition at line 800 of file analysishelper.hxx.

References getDaysInMonth(), and nMonth.

Referenced by getDaysInMonth(), and getDaysInMonthRange().

◆ getDaysInMonth() [2/2]

sal_uInt16 sca::analysis::ScaDate::getDaysInMonth ( sal_uInt16  _nMon) const
inlineprivate
Returns
count of days in given month

Definition at line 805 of file analysishelper.hxx.

References b30Days, sca::analysis::DaysInMonth(), and nYear.

◆ getDaysInMonthRange()

sal_Int32 sca::analysis::ScaDate::getDaysInMonthRange ( sal_uInt16  nFrom,
sal_uInt16  nTo 
) const
private

@ return count of days in the given month range

Definition at line 2540 of file analysishelper.cxx.

References b30Days, and getDaysInMonth().

◆ getDaysInYearRange()

sal_Int32 sca::analysis::ScaDate::getDaysInYearRange ( sal_uInt16  nFrom,
sal_uInt16  nTo 
) const
private

@ return count of days in the given year range

Definition at line 2556 of file analysishelper.cxx.

References b30Days, and sca::analysis::GetDaysInYears().

◆ getDiff()

sal_Int32 sca::analysis::ScaDate::getDiff ( const ScaDate rFrom,
const ScaDate rTo 
)
static
Returns
the number of days between the two dates
Exceptions
css::lang::IllegalArgumentException

Definition at line 2598 of file analysishelper.cxx.

References aFrom, aTo, b30Days, bUSMode, sca::analysis::DaysInMonth(), getDiff(), nDay, and nMonth.

Referenced by sca::analysis::GetCoupdaybs(), sca::analysis::GetCoupdays(), sca::analysis::GetCoupdaysnc(), and getDiff().

◆ getMonth()

sal_uInt16 sca::analysis::ScaDate::getMonth ( ) const
inline
Returns
the current month.

Definition at line 771 of file analysishelper.hxx.

References nMonth.

Referenced by sca::analysis::GetCoupnum().

◆ getYear()

sal_uInt16 sca::analysis::ScaDate::getYear ( ) const
inline
Returns
the current year.

Definition at line 773 of file analysishelper.hxx.

References nYear.

Referenced by sca::analysis::GetCoupnum(), sca::analysis::lcl_GetCoupncd(), and sca::analysis::lcl_GetCouppcd().

◆ operator<()

bool sca::analysis::ScaDate::operator< ( const ScaDate rCmp) const

Definition at line 2655 of file analysishelper.cxx.

References bLastDay, nDay, nMonth, nOrigDay, and nYear.

◆ operator<=()

bool sca::analysis::ScaDate::operator<= ( const ScaDate rCmp) const
inline

Definition at line 795 of file analysishelper.hxx.

◆ operator=()

ScaDate & sca::analysis::ScaDate::operator= ( const ScaDate rCopy)

Definition at line 2507 of file analysishelper.cxx.

References b30Days, bLastDay, bLastDayMode, bUSMode, nDay, nMonth, nOrigDay, and nYear.

◆ operator>()

bool sca::analysis::ScaDate::operator> ( const ScaDate rCmp) const
inline

Definition at line 796 of file analysishelper.hxx.

◆ operator>=()

bool sca::analysis::ScaDate::operator>= ( const ScaDate rCmp) const
inline

Definition at line 797 of file analysishelper.hxx.

◆ setDay()

void sca::analysis::ScaDate::setDay ( )
private

is true, if the US method of 30-day-calculations is used.

Calculates nDay from nOrigDay and current date.

Definition at line 2523 of file analysishelper.cxx.

References b30Days, bLastDay, sca::analysis::DaysInMonth(), nDay, nMonth, nOrigDay, and nYear.

Referenced by addMonths(), addYears(), ScaDate(), and setYear().

◆ setYear()

void sca::analysis::ScaDate::setYear ( sal_uInt16  nNewYear)
inline

sets the given year, adjusts day

Definition at line 810 of file analysishelper.hxx.

References nYear, and setDay().

Referenced by sca::analysis::lcl_GetCoupncd(), and sca::analysis::lcl_GetCouppcd().

Member Data Documentation

◆ b30Days

bool sca::analysis::ScaDate::b30Days
private

is true, if original date was the last day in month.

Definition at line 735 of file analysishelper.hxx.

Referenced by getDaysInMonth(), getDaysInMonthRange(), getDaysInYearRange(), getDiff(), operator=(), ScaDate(), and setDay().

◆ bLastDay

bool sca::analysis::ScaDate::bLastDay
private

if true, recalculate nDay after every calculation.

Definition at line 734 of file analysishelper.hxx.

Referenced by getDate(), operator<(), operator=(), ScaDate(), and setDay().

◆ bLastDayMode

bool sca::analysis::ScaDate::bLastDayMode
private

is the current year.

Definition at line 733 of file analysishelper.hxx.

Referenced by getDate(), operator=(), and ScaDate().

◆ bUSMode

bool sca::analysis::ScaDate::bUSMode
private

is true, if every month has 30 days in calculations.

Definition at line 736 of file analysishelper.hxx.

Referenced by getDiff(), operator=(), and ScaDate().

◆ nDay

sal_uInt16 sca::analysis::ScaDate::nDay
private

is the day of the original date.

Definition at line 730 of file analysishelper.hxx.

Referenced by getDiff(), operator<(), operator=(), and setDay().

◆ nMonth

sal_uInt16 sca::analysis::ScaDate::nMonth
private

is the calculated day depending on the current month/year.

Definition at line 731 of file analysishelper.hxx.

Referenced by addMonths(), getDate(), getDaysInMonth(), getDiff(), getMonth(), operator<(), operator=(), ScaDate(), and setDay().

◆ nOrigDay

sal_uInt16 sca::analysis::ScaDate::nOrigDay
private

Definition at line 729 of file analysishelper.hxx.

Referenced by getDate(), operator<(), operator=(), ScaDate(), and setDay().

◆ nYear

sal_uInt16 sca::analysis::ScaDate::nYear
private

is the current month (one-based).

Definition at line 732 of file analysishelper.hxx.

Referenced by doAddYears(), getDate(), getDaysInMonth(), getYear(), operator<(), operator=(), ScaDate(), setDay(), and setYear().


The documentation for this class was generated from the following files: