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

Go to the source code of this file.

Classes

struct  TimeDelta
 Class or struct representing a positive or negative delta of a number of nanoseconds, seconds, minutes, hours, days, or weeks. More...
 

Functions

struct TimeDelta TimeDelta_from_nanoseconds (int_delta nanoseconds)
 Create a new TimeDelta based on a positive or negative number of nanoseconds. More...
 
void TimeDelta_ptr_from_nanoseconds (struct TimeDelta *const result, int_delta nanoseconds)
 Create a new TimeDelta based on a positive or negative number of nanoseconds. More...
 
struct TimeDelta TimeDelta_from_microseconds (int_delta microseconds)
 Create a new TimeDelta based on a positive or negative number of microseconds. More...
 
void TimeDelta_ptr_from_microseconds (struct TimeDelta *const result, int_delta microseconds)
 Create a new TimeDelta based on a positive or negative number of microseconds. More...
 
struct TimeDelta TimeDelta_from_milliseconds (int_delta milliseconds)
 Create a new TimeDelta based on a positive or negative number of milliseconds. More...
 
void TimeDelta_ptr_from_milliseconds (struct TimeDelta *const result, int_delta milliseconds)
 Create a new TimeDelta based on a positive or negative number of milliseconds. More...
 
struct TimeDelta TimeDelta_from_seconds (int_delta seconds)
 Create a new TimeDelta based on a positive or negative number of seconds. More...
 
void TimeDelta_ptr_from_seconds (struct TimeDelta *const result, int_delta seconds)
 Create a new TimeDelta based on a positive or negative number of seconds. More...
 
struct TimeDelta TimeDelta_from_minutes (int_delta minutes)
 Create a new TimeDelta based on a positive or negative number of minutes. More...
 
void TimeDelta_ptr_from_minutes (struct TimeDelta *const result, int_delta minutes)
 Create a new TimeDelta based on a positive or negative number of minutes. More...
 
struct TimeDelta TimeDelta_from_hours (int_delta hours)
 Create a new TimeDelta based on a positive or negative number of hours. More...
 
void TimeDelta_ptr_from_hours (struct TimeDelta *const result, int_delta hours)
 Create a new TimeDelta based on a positive or negative number of hours. More...
 
struct TimeDelta TimeDelta_from_days (int_delta days)
 Create a new TimeDelta based on a positive or negative number of days. More...
 
void TimeDelta_ptr_from_days (struct TimeDelta *const result, int_delta days)
 Create a new TimeDelta based on a positive or negative number of days. More...
 
struct TimeDelta TimeDelta_from_weeks (int_delta weeks)
 Create a new TimeDelta based on a positive or negative number of weeks. More...
 
void TimeDelta_ptr_from_weeks (struct TimeDelta *const result, int_delta weeks)
 Create a new TimeDelta based on a positive or negative number of weeks. More...
 
struct TimeDelta TimeDelta_zero (void)
 Create a new TimeDelta initialized to zero time. More...
 
void TimeDelta_ptr_zero (struct TimeDelta *const result)
 Create a new TimeDelta initialized to zero time. More...
 
int_delta TimeDelta_nanoseconds (const struct TimeDelta *const self)
 Get the number of nanoseconds represented by a TimeDelta. More...
 
int_delta TimeDelta_microseconds (const struct TimeDelta *const self)
 Get the number of microseconds represented by a TimeDelta. More...
 
double TimeDelta_microseconds_decimal (const struct TimeDelta *const self)
 Get the number of microseconds represented by a TimeDelta, with a fractional part if necessary. More...
 
int_delta TimeDelta_milliseconds (const struct TimeDelta *const self)
 Get the number of milliseconds represented by a TimeDelta. More...
 
double TimeDelta_milliseconds_decimal (const struct TimeDelta *const self)
 Get the number of milliseconds represented by a TimeDelta, with a fractional part if necessary. More...
 
int_delta TimeDelta_seconds (const struct TimeDelta *const self)
 Get the number of seconds represented by a TimeDelta. More...
 
double TimeDelta_seconds_decimal (const struct TimeDelta *const self)
 Get the number of seconds represented by a TimeDelta, with a fractional part if necessary. More...
 
int_delta TimeDelta_minutes (const struct TimeDelta *const self)
 Get the number of minutes represented by a TimeDelta. More...
 
double TimeDelta_minutes_decimal (const struct TimeDelta *const self)
 Get the number of minutes represented by a TimeDelta, with a fractional part if necessary. More...
 
int_delta TimeDelta_hours (const struct TimeDelta *const self)
 Get the number of hours represented by a TimeDelta. More...
 
double TimeDelta_hours_decimal (const struct TimeDelta *const self)
 Get the number of hours represented by a TimeDelta, with a fractional part if necessary. More...
 
int_delta TimeDelta_days (const struct TimeDelta *const self)
 Get the number of days represented by a TimeDelta. More...
 
double TimeDelta_days_decimal (const struct TimeDelta *const self)
 Get the number of days represented by a TimeDelta, with a fractional part if necessary. More...
 
int_delta TimeDelta_weeks (const struct TimeDelta *const self)
 Get the number of weeks represented by a TimeDelta. More...
 
double TimeDelta_weeks_decimal (const struct TimeDelta *const self)
 Get the number of weeks represented by a TimeDelta, with a fractional part if necessary. More...
 
struct DayDelta TimeDelta_to_DayDelta_truncated (const struct TimeDelta *const self)
 Convert a TimeDelta into a DayDelta, rounding towards zero if the TimeDelta does not represent an exact number of days. More...
 
struct DayDelta TimeDelta_to_DayDelta_rounded (const struct TimeDelta *const self)
 Convert a TimeDelta into a DayDelta, rounding to the nearest day if the TimeDelta does not represent an exact number of days. More...
 
struct DayDelta TimeDelta_to_DayDelta_abs_ceil (const struct TimeDelta *const self)
 Convert a TimeDelta into a DayDelta, rounding away from zero if the TimeDelta does not represent an exact number of days. More...
 
present_bool TimeDelta_is_negative (const struct TimeDelta *const self)
 Determine whether a TimeDelta is negative. More...
 
void TimeDelta_negate (struct TimeDelta *const self)
 Negate a TimeDelta, making it negative if it was positive or positive if it was negative. More...
 
void TimeDelta_multiply_by (struct TimeDelta *const self, const long scale_factor)
 Scale a TimeDelta by multiplying it by an integer scale factor. More...
 
void TimeDelta_multiply_by_decimal (struct TimeDelta *const self, const double scale_factor)
 Scale a TimeDelta by multiplying it by a floating point scale factor. More...
 
void TimeDelta_divide_by (struct TimeDelta *const self, const long scale_factor)
 Scale a TimeDelta by dividing it by an integer scale factor. More...
 
void TimeDelta_divide_by_decimal (struct TimeDelta *const self, const double scale_factor)
 Scale a TimeDelta by dividing it by a floating point scale factor. More...
 
void TimeDelta_add (struct TimeDelta *const self, const struct TimeDelta *const other)
 Add another TimeDelta to a TimeDelta. More...
 
void TimeDelta_add_DayDelta (struct TimeDelta *const self, const struct DayDelta *const other)
 Add a DayDelta to a TimeDelta. More...
 
void TimeDelta_subtract (struct TimeDelta *const self, const struct TimeDelta *const other)
 Subtract another TimeDelta from a TimeDelta. More...
 
void TimeDelta_subtract_DayDelta (struct TimeDelta *const self, const struct DayDelta *const other)
 Subtract a DayDelta from a TimeDelta. More...
 
short TimeDelta_compare (const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
 Compare two TimeDelta instances. More...
 
short TimeDelta_compare_to_DayDelta (const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
 Compare a TimeDelta to a DayDelta. More...
 
present_bool TimeDelta_equal (const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
 Determine whether two TimeDelta instances are equal (lhs == rhs). More...
 
present_bool TimeDelta_equal_DayDelta (const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
 Determine whether a TimeDelta is equal to a DayDelta (lhs == rhs). More...
 
present_bool TimeDelta_less_than (const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
 Determine whether a TimeDelta is less than another TimeDelta (lhs < rhs). More...
 
present_bool TimeDelta_less_than_DayDelta (const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
 Determine whether a TimeDelta is less than a DayDelta (lhs < rhs). More...
 
present_bool TimeDelta_less_than_or_equal (const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
 Determine whether a TimeDelta is less than or equal to another TimeDelta (lhs <= rhs). More...
 
present_bool TimeDelta_less_than_or_equal_DayDelta (const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
 Determine whether a TimeDelta is less than or equal to a DayDelta (lhs <= rhs). More...
 
present_bool TimeDelta_greater_than (const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
 Determine whether a TimeDelta is greater than another TimeDelta (lhs > rhs). More...
 
present_bool TimeDelta_greater_than_DayDelta (const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
 Determine whether a TimeDelta is greater than a DayDelta (lhs > rhs). More...
 
present_bool TimeDelta_greater_than_or_equal (const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
 Determine whether a TimeDelta is greater than or equal to another TimeDelta (lhs >= rhs). More...
 
present_bool TimeDelta_greater_than_or_equal_DayDelta (const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
 Determine whether a TimeDelta is greater than or equal to a DayDelta (lhs >= rhs). More...
 

Function Documentation

struct TimeDelta TimeDelta_from_nanoseconds ( int_delta  nanoseconds)

Create a new TimeDelta based on a positive or negative number of nanoseconds.

void TimeDelta_ptr_from_nanoseconds ( struct TimeDelta *const  result,
int_delta  nanoseconds 
)

Create a new TimeDelta based on a positive or negative number of nanoseconds.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_microseconds ( int_delta  microseconds)

Create a new TimeDelta based on a positive or negative number of microseconds.

void TimeDelta_ptr_from_microseconds ( struct TimeDelta *const  result,
int_delta  microseconds 
)

Create a new TimeDelta based on a positive or negative number of microseconds.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_milliseconds ( int_delta  milliseconds)

Create a new TimeDelta based on a positive or negative number of milliseconds.

void TimeDelta_ptr_from_milliseconds ( struct TimeDelta *const  result,
int_delta  milliseconds 
)

Create a new TimeDelta based on a positive or negative number of milliseconds.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_seconds ( int_delta  seconds)

Create a new TimeDelta based on a positive or negative number of seconds.

void TimeDelta_ptr_from_seconds ( struct TimeDelta *const  result,
int_delta  seconds 
)

Create a new TimeDelta based on a positive or negative number of seconds.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_minutes ( int_delta  minutes)

Create a new TimeDelta based on a positive or negative number of minutes.

void TimeDelta_ptr_from_minutes ( struct TimeDelta *const  result,
int_delta  minutes 
)

Create a new TimeDelta based on a positive or negative number of minutes.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_hours ( int_delta  hours)

Create a new TimeDelta based on a positive or negative number of hours.

void TimeDelta_ptr_from_hours ( struct TimeDelta *const  result,
int_delta  hours 
)

Create a new TimeDelta based on a positive or negative number of hours.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_days ( int_delta  days)

Create a new TimeDelta based on a positive or negative number of days.

void TimeDelta_ptr_from_days ( struct TimeDelta *const  result,
int_delta  days 
)

Create a new TimeDelta based on a positive or negative number of days.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
struct TimeDelta TimeDelta_from_weeks ( int_delta  weeks)

Create a new TimeDelta based on a positive or negative number of weeks.

void TimeDelta_ptr_from_weeks ( struct TimeDelta *const  result,
int_delta  weeks 
)

Create a new TimeDelta based on a positive or negative number of weeks.

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

Create a new TimeDelta initialized to zero time.

void TimeDelta_ptr_zero ( struct TimeDelta *const  result)

Create a new TimeDelta initialized to zero time.

Parameters
[out]resultA pointer to a struct TimeDelta for the result.
int_delta TimeDelta_nanoseconds ( const struct TimeDelta *const  self)

Get the number of nanoseconds represented by a TimeDelta.

int_delta TimeDelta_microseconds ( const struct TimeDelta *const  self)

Get the number of microseconds represented by a TimeDelta.

If the TimeDelta does not represent an exact number of microseconds, the return value will be truncated.

double TimeDelta_microseconds_decimal ( const struct TimeDelta *const  self)

Get the number of microseconds represented by a TimeDelta, with a fractional part if necessary.

int_delta TimeDelta_milliseconds ( const struct TimeDelta *const  self)

Get the number of milliseconds represented by a TimeDelta.

If the TimeDelta does not represent an exact number of milliseconds, the return value will be truncated.

double TimeDelta_milliseconds_decimal ( const struct TimeDelta *const  self)

Get the number of milliseconds represented by a TimeDelta, with a fractional part if necessary.

int_delta TimeDelta_seconds ( const struct TimeDelta *const  self)

Get the number of seconds represented by a TimeDelta.

If the TimeDelta does not represent an exact number of seconds, the returned value will be truncated.

double TimeDelta_seconds_decimal ( const struct TimeDelta *const  self)

Get the number of seconds represented by a TimeDelta, with a fractional part if necessary.

int_delta TimeDelta_minutes ( const struct TimeDelta *const  self)

Get the number of minutes represented by a TimeDelta.

If the TimeDelta does not represent an exact number of minutes, the returned value will be truncated.

double TimeDelta_minutes_decimal ( const struct TimeDelta *const  self)

Get the number of minutes represented by a TimeDelta, with a fractional part if necessary.

int_delta TimeDelta_hours ( const struct TimeDelta *const  self)

Get the number of hours represented by a TimeDelta.

If the TimeDelta does not represent an exact number of hours, the returned value will be truncated.

double TimeDelta_hours_decimal ( const struct TimeDelta *const  self)

Get the number of hours represented by a TimeDelta, with a fractional part if necessary.

int_delta TimeDelta_days ( const struct TimeDelta *const  self)

Get the number of days represented by a TimeDelta.

If the TimeDelta does not represent an exact number of days, the returned value will be truncated.

double TimeDelta_days_decimal ( const struct TimeDelta *const  self)

Get the number of days represented by a TimeDelta, with a fractional part if necessary.

int_delta TimeDelta_weeks ( const struct TimeDelta *const  self)

Get the number of weeks represented by a TimeDelta.

If the TimeDelta does not represent an exact number of weeks, the returned value will be truncated.

double TimeDelta_weeks_decimal ( const struct TimeDelta *const  self)

Get the number of weeks represented by a TimeDelta, with a fractional part if necessary.

struct DayDelta TimeDelta_to_DayDelta_truncated ( const struct TimeDelta *const  self)

Convert a TimeDelta into a DayDelta, rounding towards zero if the TimeDelta does not represent an exact number of days.

struct DayDelta TimeDelta_to_DayDelta_rounded ( const struct TimeDelta *const  self)

Convert a TimeDelta into a DayDelta, rounding to the nearest day if the TimeDelta does not represent an exact number of days.

struct DayDelta TimeDelta_to_DayDelta_abs_ceil ( const struct TimeDelta *const  self)

Convert a TimeDelta into a DayDelta, rounding away from zero if the TimeDelta does not represent an exact number of days.

present_bool TimeDelta_is_negative ( const struct TimeDelta *const  self)

Determine whether a TimeDelta is negative.

void TimeDelta_negate ( struct TimeDelta *const  self)

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

void TimeDelta_multiply_by ( struct TimeDelta *const  self,
const long  scale_factor 
)

Scale a TimeDelta by multiplying it by an integer scale factor.

void TimeDelta_multiply_by_decimal ( struct TimeDelta *const  self,
const double  scale_factor 
)

Scale a TimeDelta by multiplying it by a floating point scale factor.

void TimeDelta_divide_by ( struct TimeDelta *const  self,
const long  scale_factor 
)

Scale a TimeDelta by dividing it by an integer scale factor.

void TimeDelta_divide_by_decimal ( struct TimeDelta *const  self,
const double  scale_factor 
)

Scale a TimeDelta by dividing it by a floating point scale factor.

void TimeDelta_add ( struct TimeDelta *const  self,
const struct TimeDelta *const  other 
)

Add another TimeDelta to a TimeDelta.

The second TimeDelta parameter is added to the first.

void TimeDelta_add_DayDelta ( struct TimeDelta *const  self,
const struct DayDelta *const  other 
)

Add a DayDelta to a TimeDelta.

The DayDelta parameter is added to the TimeDelta.

void TimeDelta_subtract ( struct TimeDelta *const  self,
const struct TimeDelta *const  other 
)

Subtract another TimeDelta from a TimeDelta.

The second TimeDelta parameter is subtracted from the first.

void TimeDelta_subtract_DayDelta ( struct TimeDelta *const  self,
const struct DayDelta *const  other 
)

Subtract a DayDelta from a TimeDelta.

The DayDelta parameter is subtracted from the TimeDelta.

short TimeDelta_compare ( const struct TimeDelta *const  lhs,
const struct TimeDelta *const  rhs 
)

Compare two TimeDelta 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.
short TimeDelta_compare_to_DayDelta ( const struct TimeDelta *const  lhs,
const struct DayDelta *const  rhs 
)

Compare a TimeDelta to a DayDelta.

  • 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 TimeDelta_equal ( const struct TimeDelta *const  lhs,
const struct TimeDelta *const  rhs 
)

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

present_bool TimeDelta_equal_DayDelta ( const struct TimeDelta *const  lhs,
const struct DayDelta *const  rhs 
)

Determine whether a TimeDelta is equal to a DayDelta (lhs == rhs).

present_bool TimeDelta_less_than ( const struct TimeDelta *const  lhs,
const struct TimeDelta *const  rhs 
)

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

present_bool TimeDelta_less_than_DayDelta ( const struct TimeDelta *const  lhs,
const struct DayDelta *const  rhs 
)

Determine whether a TimeDelta is less than a DayDelta (lhs < rhs).

present_bool TimeDelta_less_than_or_equal ( const struct TimeDelta *const  lhs,
const struct TimeDelta *const  rhs 
)

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

present_bool TimeDelta_less_than_or_equal_DayDelta ( const struct TimeDelta *const  lhs,
const struct DayDelta *const  rhs 
)

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

present_bool TimeDelta_greater_than ( const struct TimeDelta *const  lhs,
const struct TimeDelta *const  rhs 
)

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

present_bool TimeDelta_greater_than_DayDelta ( const struct TimeDelta *const  lhs,
const struct DayDelta *const  rhs 
)

Determine whether a TimeDelta is greater than a DayDelta (lhs > rhs).

present_bool TimeDelta_greater_than_or_equal ( const struct TimeDelta *const  lhs,
const struct TimeDelta *const  rhs 
)

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

present_bool TimeDelta_greater_than_or_equal_DayDelta ( const struct TimeDelta *const  lhs,
const struct DayDelta *const  rhs 
)

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