Present  0.9
 All Classes Files Functions Variables Typedefs Friends Macros Pages
month-delta.h File Reference

Go to the source code of this file.

Classes

struct  MonthDelta
 Class or struct representing a positive or negative delta of a number of months or years. More...
 

Functions

struct MonthDelta MonthDelta_from_months (int_month_delta months)
 Create a new MonthDelta based on a positive or negative number of months. More...
 
void MonthDelta_ptr_from_months (struct MonthDelta *const result, int_month_delta months)
 Create a new MonthDelta based on a positive or negative number of months. More...
 
struct MonthDelta MonthDelta_from_years (int_year_delta years)
 Create a new MonthDelta based on a positive or negative number of years. More...
 
void MonthDelta_ptr_from_years (struct MonthDelta *const result, int_year_delta years)
 Create a new MonthDelta based on a positive or negative number of years. More...
 
struct MonthDelta MonthDelta_zero (void)
 Create a new MonthDelta initialized to zero months. More...
 
void MonthDelta_ptr_zero (struct MonthDelta *const result)
 Create a new MonthDelta initialized to zero months. More...
 
int_month_delta MonthDelta_months (const struct MonthDelta *const self)
 Get the number of months represented by a MonthDelta. More...
 
int_year_delta MonthDelta_years (const struct MonthDelta *const self)
 Get the number of years represented by a MonthDelta. More...
 
double MonthDelta_years_decimal (const struct MonthDelta *const self)
 Get the number of years represented by a MonthDelta, with a fractional part if necessary. More...
 
present_bool MonthDelta_is_negative (const struct MonthDelta *const self)
 Determine whether a MonthDelta is negative. More...
 
void MonthDelta_negate (struct MonthDelta *const self)
 Negate a MonthDelta, making it negative if it was positive or positive if it was negative. More...
 
void MonthDelta_multiply_by (struct MonthDelta *const self, long scale_factor)
 Scale a MonthDelta by multiplying it by a scale factor. More...
 
void MonthDelta_divide_by (struct MonthDelta *const self, long scale_factor)
 Scale a MonthDelta by dividing it by a scale factor. More...
 
void MonthDelta_add (struct MonthDelta *const self, const struct MonthDelta *const other)
 Add another MonthDelta to a MonthDelta. More...
 
void MonthDelta_subtract (struct MonthDelta *const self, const struct MonthDelta *const other)
 Subtract another MonthDelta from a MonthDelta. More...
 
short MonthDelta_compare (const struct MonthDelta *const lhs, const struct MonthDelta *const rhs)
 Compare two MonthDelta instances. More...
 
present_bool MonthDelta_equal (const struct MonthDelta *const lhs, const struct MonthDelta *const rhs)
 Determine whether two MonthDelta instances are equal (lhs == rhs). More...
 
present_bool MonthDelta_less_than (const struct MonthDelta *const lhs, const struct MonthDelta *const rhs)
 Determine whether a MonthDelta is less than another MonthDelta (lhs < rhs). More...
 
present_bool MonthDelta_less_than_or_equal (const struct MonthDelta *const lhs, const struct MonthDelta *const rhs)
 Determine whether a MonthDelta is less than or equal to another MonthDelta (lhs <= rhs). More...
 
present_bool MonthDelta_greater_than (const struct MonthDelta *const lhs, const struct MonthDelta *const rhs)
 Determine whether a MonthDelta is greater than another MonthDelta (lhs > rhs). More...
 
present_bool MonthDelta_greater_than_or_equal (const struct MonthDelta *const lhs, const struct MonthDelta *const rhs)
 Determine whether a MonthDelta is greater than or equal to another MonthDelta (lhs >= rhs). More...
 

Function Documentation

struct MonthDelta MonthDelta_from_months ( int_month_delta  months)

Create a new MonthDelta based on a positive or negative number of months.

void MonthDelta_ptr_from_months ( struct MonthDelta *const  result,
int_month_delta  months 
)

Create a new MonthDelta based on a positive or negative number of months.

Parameters
[out]resultA pointer to a struct MonthDelta for the result.
struct MonthDelta MonthDelta_from_years ( int_year_delta  years)

Create a new MonthDelta based on a positive or negative number of years.

void MonthDelta_ptr_from_years ( struct MonthDelta *const  result,
int_year_delta  years 
)

Create a new MonthDelta based on a positive or negative number of years.

Parameters
[out]resultA pointer to a struct MonthDelta for the result.
struct MonthDelta MonthDelta_zero ( void  )

Create a new MonthDelta initialized to zero months.

void MonthDelta_ptr_zero ( struct MonthDelta *const  result)

Create a new MonthDelta initialized to zero months.

Parameters
[out]resultA pointer to a struct MonthDelta for the result.
int_month_delta MonthDelta_months ( const struct MonthDelta *const  self)

Get the number of months represented by a MonthDelta.

int_year_delta MonthDelta_years ( const struct MonthDelta *const  self)

Get the number of years represented by a MonthDelta.

If the MonthDelta does not represent an exact number of years, the number of years will be truncated.

double MonthDelta_years_decimal ( const struct MonthDelta *const  self)

Get the number of years represented by a MonthDelta, with a fractional part if necessary.

present_bool MonthDelta_is_negative ( const struct MonthDelta *const  self)

Determine whether a MonthDelta is negative.

void MonthDelta_negate ( struct MonthDelta *const  self)

Negate a MonthDelta, making it negative if it was positive or positive if it was negative.

void MonthDelta_multiply_by ( struct MonthDelta *const  self,
long  scale_factor 
)

Scale a MonthDelta by multiplying it by a scale factor.

void MonthDelta_divide_by ( struct MonthDelta *const  self,
long  scale_factor 
)

Scale a MonthDelta by dividing it by a scale factor.

void MonthDelta_add ( struct MonthDelta *const  self,
const struct MonthDelta *const  other 
)

Add another MonthDelta to a MonthDelta.

The second MonthDelta parameter is added to the first.

void MonthDelta_subtract ( struct MonthDelta *const  self,
const struct MonthDelta *const  other 
)

Subtract another MonthDelta from a MonthDelta.

The second MonthDelta parameter is subtracted from the first.

short MonthDelta_compare ( const struct MonthDelta *const  lhs,
const struct MonthDelta *const  rhs 
)

Compare two MonthDelta instances.

  • If lhs < rhs, then a negative integer will be returned.
  • If lhs == rhs, then 0 will be returned.
  • If lhs > rhs, then a positive integer will be returned.
present_bool MonthDelta_equal ( const struct MonthDelta *const  lhs,
const struct MonthDelta *const  rhs 
)

Determine whether two MonthDelta instances are equal (lhs == rhs).

present_bool MonthDelta_less_than ( const struct MonthDelta *const  lhs,
const struct MonthDelta *const  rhs 
)

Determine whether a MonthDelta is less than another MonthDelta (lhs < rhs).

present_bool MonthDelta_less_than_or_equal ( const struct MonthDelta *const  lhs,
const struct MonthDelta *const  rhs 
)

Determine whether a MonthDelta is less than or equal to another MonthDelta (lhs <= rhs).

present_bool MonthDelta_greater_than ( const struct MonthDelta *const  lhs,
const struct MonthDelta *const  rhs 
)

Determine whether a MonthDelta is greater than another MonthDelta (lhs > rhs).

present_bool MonthDelta_greater_than_or_equal ( const struct MonthDelta *const  lhs,
const struct MonthDelta *const  rhs 
)

Determine whether a MonthDelta is greater than or equal to another MonthDelta (lhs >= rhs).