module
CnxDurationCnxDuration
represents a positive or negative duration in a particular unit of time (e.g. a (signed) number of seconds, nanoseconds, or years)
Classes
- struct CnxDuration
CnxDuration
represents a duration in a particular unit of time ACnxDuration
occurs in a particular unit of time (e.g. seconds, nanoseconds, or years), and can represent a positive or negative amount of that unit
Typedefs
- using CnxDuration = struct CnxDuration
CnxDuration
represents a duration in a particular unit of time ACnxDuration
occurs in a particular unit of time (e.g. seconds, nanoseconds, or years), and can represent a positive or negative amount of that unit
Functions
- CnxDuration cnx_duration_new(i64 count, CnxRatio period)
- Creates a new
CnxDuration
with the given count and period. - CnxDuration cnx_duration_cast(CnxDuration to_cast, CnxRatio new_period)
- Converts the given
CnxDuration
to one with a different period Converts the givenCnxDuration
to aCnxDuration
with a different period, truncating any fractional portion caused by the conversion. - CnxDuration cnx_duration_floor(CnxDuration to_floor, CnxRatio new_period)
- Converts the given
CnxDuration
to one with a different period Converts the givenCnxDuration
to aCnxDuration
with a different period, flooring any fractional portion caused by the conversion. - CnxDuration cnx_duration_ceil(CnxDuration to_ceil, CnxRatio new_period)
- Converts the given
CnxDuration
to one with a different period Converts the givenCnxDuration
to aCnxDuration
with a different period, taking the ceiling of any fractional portion caused by the conversion. - CnxDuration cnx_duration_round(CnxDuration to_round, CnxRatio new_period)
- Converts the given
CnxDuration
to one with a different period Converts the givenCnxDuration
to aCnxDuration
with a different period, rounding any fractional portion caused by the conversion. - CnxDuration cnx_duration_abs(CnxDuration duration)
- Takes the absolute value of the given `CnxDuration.
- CnxDuration cnx_duration_add(CnxDuration lhs, CnxDuration rhs)
- Casts
rhs
to the same period aslhs
, then adds the two. - CnxDuration cnx_duration_add_scalar(CnxDuration lhs, i64 rhs)
- Adds
rhs
tolhs
as if it were aCnxDuration
of the same period. - CnxDuration cnx_duration_subtract(CnxDuration lhs, CnxDuration rhs)
- Casts
rhs
to the same period aslhs
, then subtractsrhs
fromlhs
- CnxDuration cnx_duration_subtract_scalar(CnxDuration lhs, i64 rhs)
- Subtracts
rhs
fromlhs
as if it were aCnxDuration
of the same period. - CnxDuration cnx_duration_multiply(CnxDuration lhs, i64 rhs)
- Multiplies
lhs
by the scalar valuerhs
- CnxDuration cnx_duration_divide(CnxDuration lhs, i64 rhs)
- Divides
lhs
by the scalar valuerhs
- bool cnx_duration_equal(CnxDuration lhs, CnxDuration rhs)
- Determines if the two
CnxDuration
s are equal. - bool cnx_duration_not_equal(CnxDuration lhs, CnxDuration rhs)
- Determines if the two
CnxDuration
s are NOT equal. - bool cnx_duration_less_than(CnxDuration lhs, CnxDuration rhs)
- Determines if
lhs
is strictly less thanrhs
. - bool cnx_duration_less_than_or_equal(CnxDuration lhs, CnxDuration rhs)
- Determines if
lhs
is less than or equal torhs
. - bool cnx_duration_greater_than(CnxDuration lhs, CnxDuration rhs)
- Determines if
lhs
is strictly greater thanrhs
. - bool cnx_duration_greater_than_or_equal(CnxDuration lhs, CnxDuration rhs)
- Determines if
lhs
is greater than or equal torhs
. - CnxCompare cnx_duration_compare(CnxDuration lhs, CnxDuration rhs)
- Performs a three-way comparison of
lhs
torhs
, determining howlhs
mathematically relates torhs
. - CnxString cnx_duration_format(const CnxFormat*restrict self, CnxFormatContext context)
- Implements the allocator-unaware part of the
CnxFormat
trait forCnxDuration
- CnxString cnx_duration_format_with_allocator(const CnxFormat*restrict self, CnxFormatContext context, CnxAllocator allocator)
- Implements the allocator-aware part of the
CnxFormat
trait forCnxDuration
-
static ImplTraitFor(CnxFormat,
CnxDuration,
cnx_
duration_ is_ specifier_ valid, cnx_ duration_ format, cnx_ duration_ format_ with_ allocator) - Implements the
CnxFormat
trait forCnxDuration
Variables
- i64 count
- The length of the duration.
- CnxRatio period
- The unit of the duration as a
CnxRatio
For example, for aCnxDuration
in milliseconds, theperiod
would becnx_milli
orcnx_milliseconds_period
- static const CnxRatio cnx_duration_valid_periods
- Valid periods for
CnxDuration
and other time-related facilities.
Defines
- #define cnx_nanoseconds_period
- Period representing nanoseconds for
CnxDuration
and other time-related facilities. - #define cnx_microseconds_period
- Period representing microseconds for
CnxDuration
and other time-related facilities. - #define cnx_milliseconds_period
- Period representing milliseconds for
CnxDuration
and other time-related facilities. - #define cnx_seconds_period
- Period representing seconds for
CnxDuration
and other time-related facilities. - #define cnx_minutes_period
- Period representing minutes for
CnxDuration
and other time-related facilities. - #define cnx_hours_period
- Period representing hours for
CnxDuration
and other time-related facilities. - #define cnx_days_period
- Period representing days for
CnxDuration
and other time-related facilities. - #define cnx_weeks_period
- Period representing weeks for
CnxDuration
and other time-related facilities. - #define cnx_months_period
- Period representing months for
CnxDuration
and other time-related facilities. - #define cnx_years_period
- Period representing years for
CnxDuration
and other time-related facilities. - #define cnx_nanoseconds(val)
- Returns a
CnxDuration
representing a number of nanoseconds. - #define cnx_microseconds(val)
- Returns a
CnxDuration
representing a number of microseconds. - #define cnx_milliseconds(val)
- Returns a
CnxDuration
representing a number of milliseconds. - #define cnx_seconds(val)
- Returns a
CnxDuration
representing a number of seconds. - #define cnx_minutes(val)
- Returns a
CnxDuration
representing a number of minutes. - #define cnx_hours(val)
- Returns a
CnxDuration
representing a number of hours. - #define cnx_days(val)
- Returns a
CnxDuration
representing a number of days. - #define cnx_weeks(val)
- Returns a
CnxDuration
representing a number of weeks. - #define cnx_months(val)
- Returns a
CnxDuration
representing a number of months. - #define cnx_years(val)
- Returns a
CnxDuration
representing a number of years.
Typedef documentation
typedef struct CnxDuration CnxDuration
#include <include/Cnx/time/Duration.h>
CnxDuration
represents a duration in a particular unit of time A CnxDuration
occurs in a particular unit of time (e.g. seconds, nanoseconds, or years), and can represent a positive or negative amount of that unit
Function documentation
CnxDuration cnx_duration_new(i64 count,
CnxRatio period)
#include <include/Cnx/time/Duration.h>
Creates a new CnxDuration
with the given count and period.
Parameters | |
---|---|
count | - The value of the duration. The number of period s it represents |
period | - The period of the duration. The unit of time it represents (e.g. seconds, hours, etc.) |
Returns | a new CnxDuration |
CnxDuration cnx_duration_cast(CnxDuration to_cast,
CnxRatio new_period)
#include <include/Cnx/time/Duration.h>
Converts the given CnxDuration
to one with a different period Converts the given CnxDuration
to a CnxDuration
with a different period, truncating any fractional portion caused by the conversion.
Parameters | |
---|---|
to_cast | - The CnxDuration to cast |
new_period | - The CnxRatio representing the new period |
Returns | to_cast converted a new period |
CnxDuration cnx_duration_floor(CnxDuration to_floor,
CnxRatio new_period)
#include <include/Cnx/time/Duration.h>
Converts the given CnxDuration
to one with a different period Converts the given CnxDuration
to a CnxDuration
with a different period, flooring any fractional portion caused by the conversion.
Parameters | |
---|---|
to_floor | - The CnxDuration to cast |
new_period | - The CnxRatio representing the new period |
Returns | to_cast converted a new period |
CnxDuration cnx_duration_ceil(CnxDuration to_ceil,
CnxRatio new_period)
#include <include/Cnx/time/Duration.h>
Converts the given CnxDuration
to one with a different period Converts the given CnxDuration
to a CnxDuration
with a different period, taking the ceiling of any fractional portion caused by the conversion.
Parameters | |
---|---|
to_ceil | - The CnxDuration to cast |
new_period | - The CnxRatio representing the new period |
Returns | to_cast converted a new period |
CnxDuration cnx_duration_round(CnxDuration to_round,
CnxRatio new_period)
#include <include/Cnx/time/Duration.h>
Converts the given CnxDuration
to one with a different period Converts the given CnxDuration
to a CnxDuration
with a different period, rounding any fractional portion caused by the conversion.
Parameters | |
---|---|
to_round | - The CnxDuration to cast |
new_period | - The CnxRatio representing the new period |
Returns | to_cast converted a new period |
CnxDuration cnx_duration_abs(CnxDuration duration)
#include <include/Cnx/time/Duration.h>
Takes the absolute value of the given `CnxDuration.
Parameters | |
---|---|
duration | - The CnxDuration to get the absolute value of |
Returns | the absolute value of duration |
CnxDuration cnx_duration_add(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Casts rhs
to the same period as lhs
, then adds the two.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to add |
rhs | - The rhs CnxDuration to add. Will be cast to the same period as lhs |
Returns | the equivalent of lhs + Cnx_duration_cast(rhs, lhs.period) |
CnxDuration cnx_duration_add_scalar(CnxDuration lhs,
i64 rhs)
#include <include/Cnx/time/Duration.h>
Adds rhs
to lhs
as if it were a CnxDuration
of the same period.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to add |
rhs | - The scalar value to add. Will be treated as a CnxDuration of the same period as lhs |
Returns | the sum of lhs and rhs |
CnxDuration cnx_duration_subtract(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Casts rhs
to the same period as lhs
, then subtracts rhs
from lhs
Parameters | |
---|---|
lhs | - The lhs CnxDuration to subtract from |
rhs | - The rhs CnxDuration to subtract. Will be cast to the same period as lhs |
Returns | the equivalent of lhs - Cnx_duration_cast(rhs, lhs.period) |
CnxDuration cnx_duration_subtract_scalar(CnxDuration lhs,
i64 rhs)
#include <include/Cnx/time/Duration.h>
Subtracts rhs
from lhs
as if it were a CnxDuration
of the same period.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to subtract from |
rhs | - The scalar value to subtract. Will be treated as a CnxDuration of the same period as lhs |
Returns | the difference between lhs and rhs |
CnxDuration cnx_duration_multiply(CnxDuration lhs,
i64 rhs)
#include <include/Cnx/time/Duration.h>
Multiplies lhs
by the scalar value rhs
Parameters | |
---|---|
lhs | - The lhs CnxDuration to multiply |
rhs | - The scalar value to multiply by. |
Returns | the product of lhs and rhs |
CnxDuration cnx_duration_divide(CnxDuration lhs,
i64 rhs)
#include <include/Cnx/time/Duration.h>
Divides lhs
by the scalar value rhs
Parameters | |
---|---|
lhs | - The lhs CnxDuration to divide |
rhs | - The scalar value to divide by. |
Returns | the quotient of lhs and rhs |
bool cnx_duration_equal(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Determines if the two CnxDuration
s are equal.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | whether lhs and rhs are equivalent |
Determines if the two CnxDuration
s are equal by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
bool cnx_duration_not_equal(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Determines if the two CnxDuration
s are NOT equal.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | whether lhs and rhs are NOT equivalent |
Determines if the two CnxDuration
s are NOT equal by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
bool cnx_duration_less_than(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Determines if lhs
is strictly less than rhs
.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | whether lhs is strictly less than rhs |
Determines if lhs
is strictly less than rhs
by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
bool cnx_duration_less_than_or_equal(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Determines if lhs
is less than or equal to rhs
.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | whether lhs is less than or equal to rhs |
Determines if lhs
is less than or equal to rhs
by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
bool cnx_duration_greater_than(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Determines if lhs
is strictly greater than rhs
.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | whether lhs is strictly greater than rhs |
Determines if lhs
is strictly greater than rhs
by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
bool cnx_duration_greater_than_or_equal(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Determines if lhs
is greater than or equal to rhs
.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | whether lhs is greater than or equal to rhs |
Determines if lhs
is greater than or equal to rhs
by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
CnxCompare cnx_duration_compare(CnxDuration lhs,
CnxDuration rhs)
#include <include/Cnx/time/Duration.h>
Performs a three-way comparison of lhs
to rhs
, determining how lhs
mathematically relates to rhs
.
Parameters | |
---|---|
lhs | - The lhs CnxDuration to compare |
rhs | - The rhs CnxDuration to compare. |
Returns | how lhs mathematically compares to rhs |
Performs a three-way comparison of lhs
to rhs
by comparing them in the most precise period of the two. For example, if lhs
's period is cnx_milliseconds_period
and rhs
's period is cnx_seconds_period
, rhs
will be converted to a CnxDuration
in cnx_milliseconds_period
before the comparison.
CnxString cnx_duration_format(const CnxFormat*restrict self,
CnxFormatContext context)
#include <include/Cnx/time/Duration.h>
Implements the allocator-unaware part of the CnxFormat
trait for CnxDuration
Parameters | |
---|---|
self | - The CnxDuration to format, as its CnxFormat trait representation |
context | - The CnxFormatContext specifying how formatting should be done default in the format string |
Returns | self formatted as a CnxString |
CnxString cnx_duration_format_with_allocator(const CnxFormat*restrict self,
CnxFormatContext context,
CnxAllocator allocator)
#include <include/Cnx/time/Duration.h>
Implements the allocator-aware part of the CnxFormat
trait for CnxDuration
Parameters | |
---|---|
self | - The CnxDuration to format, as its CnxFormat trait representation |
context | - The CnxFormatContext specifying how formatting should be done |
allocator | - The CnxAllocator to allocate memory with |
Returns | self formatted as a CnxString |
static ImplTraitFor(CnxFormat,
CnxDuration,
cnx_ duration_ is_ specifier_ valid,
cnx_ duration_ format,
cnx_ duration_ format_ with_ allocator)
#include <include/Cnx/time/Duration.h>
Implements the CnxFormat
trait for CnxDuration
Variable documentation
i64 count
#include <include/Cnx/time/Duration.h>
The length of the duration.
CnxRatio period
#include <include/Cnx/time/Duration.h>
The unit of the duration as a CnxRatio
For example, for a CnxDuration
in milliseconds, the period
would be cnx_milli
or cnx_milliseconds_period
static const CnxRatio cnx_duration_valid_periods
#include <include/Cnx/time/Duration.h>
Valid periods for CnxDuration
and other time-related facilities.
Define documentation
#define cnx_nanoseconds_period
#include <include/Cnx/time/Duration.h>
Period representing nanoseconds for CnxDuration
and other time-related facilities.
#define cnx_microseconds_period
#include <include/Cnx/time/Duration.h>
Period representing microseconds for CnxDuration
and other time-related facilities.
#define cnx_milliseconds_period
#include <include/Cnx/time/Duration.h>
Period representing milliseconds for CnxDuration
and other time-related facilities.
#define cnx_seconds_period
#include <include/Cnx/time/Duration.h>
Period representing seconds for CnxDuration
and other time-related facilities.
#define cnx_minutes_period
#include <include/Cnx/time/Duration.h>
Period representing minutes for CnxDuration
and other time-related facilities.
#define cnx_hours_period
#include <include/Cnx/time/Duration.h>
Period representing hours for CnxDuration
and other time-related facilities.
#define cnx_days_period
#include <include/Cnx/time/Duration.h>
Period representing days for CnxDuration
and other time-related facilities.
#define cnx_weeks_period
#include <include/Cnx/time/Duration.h>
Period representing weeks for CnxDuration
and other time-related facilities.
#define cnx_months_period
#include <include/Cnx/time/Duration.h>
Period representing months for CnxDuration
and other time-related facilities.
#define cnx_years_period
#include <include/Cnx/time/Duration.h>
Period representing years for CnxDuration
and other time-related facilities.
#define cnx_nanoseconds(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of nanoseconds.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of nanoseconds |
#define cnx_microseconds(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of microseconds.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of microseconds |
#define cnx_milliseconds(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of milliseconds.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of milliseconds |
#define cnx_seconds(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of seconds.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of seconds |
#define cnx_minutes(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of minutes.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of minutes |
#define cnx_hours(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of hours.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of hours |
#define cnx_days(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of days.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of days |
#define cnx_weeks(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of weeks.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of weeks |
#define cnx_months(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of months.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of months |
#define cnx_years(val)
#include <include/Cnx/time/Duration.h>
Returns a CnxDuration
representing a number of years.
Parameters | |
---|---|
val | - The number of nanoseconds |
Returns | a CnxDuration representing a number of years |