17 #include "present/internal/cpp-guard.h"
18 #include "present/internal/header-utils.h"
21 #include "present/internal/present-time-delta-data.h"
23 #ifndef _PRESENT_TIME_DELTA_H_
24 #define _PRESENT_TIME_DELTA_H_
42 struct PresentTimeDeltaData data_;
78 double microseconds_decimal()
const;
83 double milliseconds_decimal()
const;
88 double seconds_decimal()
const;
93 double minutes_decimal()
const;
98 double hours_decimal()
const;
103 double days_decimal()
const;
108 double weeks_decimal()
const;
111 DayDelta to_DayDelta_truncated()
const;
114 DayDelta to_DayDelta_rounded()
const;
117 DayDelta to_DayDelta_abs_ceil()
const;
120 bool is_negative()
const;
132 TimeDelta & operator*=(
const long & scale_factor);
134 TimeDelta & operator*=(
const double & scale_factor);
136 TimeDelta & operator/=(
const long & scale_factor);
138 TimeDelta & operator/=(
const double & scale_factor);
143 const long & scale_factor);
147 const double & scale_factor);
151 const long & scale_factor);
155 const double & scale_factor);
520 const double scale_factor);
534 const double scale_factor);
552 const struct DayDelta *
const other);
570 const struct DayDelta *
const other);
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.
struct TimeDelta TimeDelta_from_nanoseconds(int_delta nanoseconds)
Create a new TimeDelta based on a positive or negative number of nanoseconds.
double TimeDelta_microseconds_decimal(const struct TimeDelta *const self)
Get the number of microseconds represented by a TimeDelta, with a fractional part if necessary...
struct TimeDelta TimeDelta_zero(void)
Create a new TimeDelta initialized to zero time.
struct TimeDelta TimeDelta_from_minutes(int_delta minutes)
Create a new TimeDelta based on a positive or negative number of minutes.
struct TimeDelta TimeDelta_from_microseconds(int_delta microseconds)
Create a new TimeDelta based on a positive or negative number of microseconds.
int_delta TimeDelta_minutes(const struct TimeDelta *const self)
Get the number of minutes represented by a TimeDelta.
void TimeDelta_add_DayDelta(struct TimeDelta *const self, const struct DayDelta *const other)
Add a DayDelta to a TimeDelta.
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.
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_equal(const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
Determine whether two TimeDelta instances are equal (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).
double TimeDelta_days_decimal(const struct TimeDelta *const self)
Get the number of days represented by a TimeDelta, with a fractional part if necessary.
struct TimeDelta TimeDelta_from_hours(int_delta hours)
Create a new TimeDelta based on a positive or negative number of hours.
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 exa...
double TimeDelta_hours_decimal(const struct TimeDelta *const self)
Get the number of hours represented by a TimeDelta, with a fractional part if necessary.
void TimeDelta_add(struct TimeDelta *const self, const struct TimeDelta *const other)
Add another TimeDelta to a TimeDelta.
int_delta TimeDelta_milliseconds(const struct TimeDelta *const self)
Get the number of milliseconds represented by a TimeDelta.
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_int64 int_delta
Definition: types.h:86
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_decimal(struct TimeDelta *const self, const double scale_factor)
Scale a TimeDelta by multiplying it by a floating point scale factor.
void TimeDelta_subtract(struct TimeDelta *const self, const struct TimeDelta *const other)
Subtract another TimeDelta from a TimeDelta.
struct TimeDelta TimeDelta_from_seconds(int_delta seconds)
Create a new TimeDelta based on a positive or negative number of seconds.
int_delta seconds() const
Get the number of seconds represented by a TimeDelta.
int_delta TimeDelta_seconds(const struct TimeDelta *const self)
Get the number of seconds represented by a TimeDelta.
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_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).
double TimeDelta_weeks_decimal(const struct TimeDelta *const self)
Get the number of weeks represented by a TimeDelta, with a fractional part if necessary.
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 microseconds() const
Get the number of microseconds represented by a TimeDelta.
int_delta milliseconds() const
Get the number of milliseconds represented by a TimeDelta.
int_delta TimeDelta_weeks(const struct TimeDelta *const self)
Get the number of weeks represented by a TimeDelta.
short TimeDelta_compare_to_DayDelta(const struct TimeDelta *const lhs, const struct DayDelta *const rhs)
Compare a TimeDelta to a DayDelta.
void TimeDelta_divide_by(struct TimeDelta *const self, const long scale_factor)
Scale a TimeDelta by dividing it by an integer scale factor.
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 ...
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.
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.
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.
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_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)...
int_delta nanoseconds() const
Get the number of nanoseconds represented by a TimeDelta.
int_delta hours() const
Get the number of hours represented by a TimeDelta.
int_delta minutes() const
Get the number of minutes represented by a TimeDelta.
void TimeDelta_ptr_zero(struct TimeDelta *const result)
Create a new TimeDelta initialized to zero time.
int_delta TimeDelta_days(const struct TimeDelta *const self)
Get the number of days represented by a TimeDelta.
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.
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.
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.
Class or struct representing a positive or negative delta of a number of days or weeks.
Definition: day-delta.h:40
void TimeDelta_subtract_DayDelta(struct TimeDelta *const self, const struct DayDelta *const other)
Subtract a DayDelta from a TimeDelta.
Class or struct representing a positive or negative delta of a number of nanoseconds, seconds, minutes, hours, days, or weeks.
Definition: time-delta.h:40
double TimeDelta_milliseconds_decimal(const struct TimeDelta *const self)
Get the number of milliseconds represented by a TimeDelta, with a fractional part if necessary...
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).
struct TimeDelta TimeDelta_from_days(int_delta days)
Create a new TimeDelta based on a positive or negative number of days.
int_delta TimeDelta_microseconds(const struct TimeDelta *const self)
Get the number of microseconds represented by a TimeDelta.
struct TimeDelta TimeDelta_from_weeks(int_delta weeks)
Create a new TimeDelta based on a positive or negative number of weeks.
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).
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.
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_hours(const struct TimeDelta *const self)
Get the number of hours represented by a TimeDelta.
present_bool TimeDelta_is_negative(const struct TimeDelta *const self)
Determine whether a TimeDelta is negative.
short TimeDelta_compare(const struct TimeDelta *const lhs, const struct TimeDelta *const rhs)
Compare two TimeDelta instances.
void TimeDelta_multiply_by(struct TimeDelta *const self, const long scale_factor)
Scale a TimeDelta by multiplying it by an integer scale factor.
int_delta days() const
Get the number of days represented by a TimeDelta.
struct TimeDelta TimeDelta_from_milliseconds(int_delta milliseconds)
Create a new TimeDelta based on a positive or negative number of milliseconds.
int_delta TimeDelta_nanoseconds(const struct TimeDelta *const self)
Get the number of nanoseconds represented by a TimeDelta.
bool present_bool
Definition: types.h:21
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 e...
int_delta weeks() const
Get the number of weeks represented by a TimeDelta.