Time » CnxTimePoint module

CnxTimePoint represents a specific point in time, since the UNIX epoch, represented in a particular level of precision

Classes

struct CnxTimePoint
CnxTimePoint represents a specific point in time, since the UNIX epoch, represented in a particular level of precision

Enums

enum CnxTimePointLocale { CNX_UTC_TIME = 0, CNX_LOCAL_TIME, CNX_UNKNOWN_TIME }
Indicates whether a CnxTimePoint is in UTC time, local time, or an unknown locale.

Typedefs

using CnxTimePointLocale = enum CnxTimePointLocale
Indicates whether a CnxTimePoint is in UTC time, local time, or an unknown locale.
using CnxTimePoint = struct CnxTimePoint
CnxTimePoint represents a specific point in time, since the UNIX epoch, represented in a particular level of precision

Functions

CnxTimePoint cnx_time_point_new(CnxDuration time_since_epoch)
Constructs a new CnxTimePoint representing the given time since the UNIX epoch, assuming the same precision as cnx_system_clock
CnxTimePoint cnx_time_point_new_with_clock(CnxDuration time_since_epoch, const CnxClock*restrict clock) cnx_disable_if(!clock
Constructs a new CnxTimePoint representing the given time since the UNIX epoch, with the same precision of the given CnxClock
CnxTimePoint cnx_time_point_new_with_clock_and_locale(CnxDuration time_since_epoch, const CnxClock*restrict clock, CnxTimePointLocale locale) cnx_disable_if(!clock
Constructs a new CnxTimePoint representing the given time since the UNIX epoch, with the same precision of the given CnxClock
CnxDuration cnx_time_point_time_since_epoch(CnxTimePoint self)
Returns the time since the UNIX epoch of the given CnxTimePoint
CnxTimePoint cnx_time_point_min(CnxTimePoint self)
Returns the minimum possible CnxTimePoint with the same precision as the given one.
CnxTimePoint cnx_time_point_max(CnxTimePoint self)
Returns the maximum possible CnxTimePoint with the same precision as the given one.
CnxTimePoint cnx_time_point_cast(CnxTimePoint to_cast, CnxTimePoint new_precision)
Converts the first CnxTimePoint to the same precision as the second one.
CnxTimePoint cnx_time_point_ceil(CnxTimePoint to_cast, CnxTimePoint new_precision)
Converts the first CnxTimePoint to the same precision as the second one, taking the ceiling of any fractional part in the result.
CnxTimePoint cnx_time_point_floor(CnxTimePoint to_cast, CnxTimePoint new_precision)
Converts the first CnxTimePoint to the same precision as the second one, taking the floor of any fractional part in the result.
CnxTimePoint cnx_time_point_round(CnxTimePoint to_cast, CnxTimePoint new_precision)
Converts the first CnxTimePoint to the same precision as the second one, rounding any fractional part in the result.
time_t cnx_time_point_as_time_t(CnxTimePoint to_cast)
Converts the given CnxTimePoint to time_t
CnxResult(tm)
Converts the given CnxTimePoint to tm
CnxTimePoint cnx_time_point_from_time_t(time_t time)
Converts the given time_t to a CnxTimePoint in the system clock precision.
void cnx_time_point_increment(CnxTimePoint*restrict self)
Increments the given CnxTimePoint by one unit.
void cnx_time_point_decrement(CnxTimePoint*restrict self)
Decrements the given CnxTimePoint by one unit.
CnxTimePoint cnx_time_point_add(CnxTimePoint lhs, CnxDuration rhs)
Adds the given CnxDuration to the given CnxTimePoint
CnxTimePoint cnx_time_point_subtract(CnxTimePoint lhs, CnxDuration rhs)
Subtracts the given CnxDuration from the given CnxTimePoint
CnxTimePoint cnx_time_point_add_time_point(CnxTimePoint lhs, CnxTimePoint rhs)
Adds the rhs CnxTimePoint to the lhs CnxTimePoint
CnxTimePoint cnx_time_point_subtract_time_point(CnxTimePoint lhs, CnxTimePoint rhs)
Subtracts the rhs CnxDuration from the lhs CnxTimePoint
CnxTimePoint cnx_time_point_add_scalar(CnxTimePoint lhs, i64 rhs)
Adds the given scalar value to the given CnxTimePoint as if it were a CnxTimePoint or CnxDuration in the same precision.
CnxTimePoint cnx_time_point_subtract_scalar(CnxTimePoint lhs, i64 rhs)
Subtracts the given scalar value from the given CnxTimePoint as if it were a CnxTimePoint or CnxDuration in the same precision.
bool cnx_time_point_equal(CnxTimePoint lhs, CnxTimePoint rhs)
Determines if the two CnxTimePoints are equivalent. Converts to the precision of the most precise of the two prior to comparison.
bool cnx_time_point_not_equal(CnxTimePoint lhs, CnxTimePoint rhs)
Determines if the two CnxTimePoints are NOT equivalent. Converts to the precision of the most precise of the two prior to comparison.
bool cnx_time_point_less_than(CnxTimePoint lhs, CnxTimePoint rhs)
Determines if the left-hand-side CnxTimePoint is less than the right-hand-side Converts to the precision of the most precise of the two prior to comparison.
bool cnx_time_point_less_than_or_equal(CnxTimePoint lhs, CnxTimePoint rhs)
Determines if the left-hand-side CnxTimePoint is less than or equal to the right-hand-side. Converts to the precision of the most precise of the two prior to comparison.
bool cnx_time_point_greater_than(CnxTimePoint lhs, CnxTimePoint rhs)
Determines if the left-hand-side CnxTimePoint is greater than the right-hand-side Converts to the precision of the most precise of the two prior to comparison.
bool cnx_time_point_greater_than_or_equal(CnxTimePoint lhs, CnxTimePoint rhs)
Determines if the left-hand-side CnxTimePoint is greater than or equal to the right-hand-side. Converts to the precision of the most precise of the two prior to comparison.
CnxCompare cnx_time_point_compare(CnxTimePoint lhs, CnxTimePoint rhs)
Performs a three-way comparison of lhs to rhs, determining how lhs mathematically relates to rhs. Converts to the precision of the most precise of the two prior to comparison.
CnxString cnx_time_point_format(const CnxFormat*restrict self, CnxFormatContext context)
Implements the allocator-unaware part of the CnxFormat trait for CnxTimePoint
CnxString cnx_time_point_format_with_allocator(const CnxFormat*restrict self, CnxFormatContext context, CnxAllocator allocator)
Implements the allocator-aware part of the CnxFormat trait for CnxTimePoint
static ImplTraitFor(CnxFormat, CnxTimePoint, cnx_time_point_is_specifier_valid, cnx_time_point_format, cnx_time_point_format_with_allocator)
Implements the CnxFormat trait for CnxTimePoint

Variables

CnxDuration time_since_epoch
The point in time, represented as a duration since the UNIX epoch.
const CnxClock* clock
The clock associated with this time point.

Enum documentation

enum CnxTimePointLocale

Indicates whether a CnxTimePoint is in UTC time, local time, or an unknown locale.

Typedef documentation

typedef enum CnxTimePointLocale CnxTimePointLocale

Indicates whether a CnxTimePoint is in UTC time, local time, or an unknown locale.

typedef struct CnxTimePoint CnxTimePoint

CnxTimePoint represents a specific point in time, since the UNIX epoch, represented in a particular level of precision

Function documentation

CnxTimePoint cnx_time_point_new(CnxDuration time_since_epoch)

Constructs a new CnxTimePoint representing the given time since the UNIX epoch, assuming the same precision as cnx_system_clock

Parameters
time_since_epoch - The time since the UNIX epoch. The precision of the CnxTimePoint will be the period of this CnxDuration
Returns a CnxTimePoint representing the given time since the epoch

CnxTimePoint cnx_time_point_new_with_clock(CnxDuration time_since_epoch, const CnxClock*restrict clock) cnx_disable_if(!clock

Constructs a new CnxTimePoint representing the given time since the UNIX epoch, with the same precision of the given CnxClock

Parameters
time_since_epoch - The time since the UNIX epoch. The precision of the CnxTimePoint will be the period of this CnxDuration
clock - The clock associated with this time point
Returns a CnxTimePoint representing the given time since the epoch

CnxTimePoint cnx_time_point_new_with_clock_and_locale(CnxDuration time_since_epoch, const CnxClock*restrict clock, CnxTimePointLocale locale) cnx_disable_if(!clock

Constructs a new CnxTimePoint representing the given time since the UNIX epoch, with the same precision of the given CnxClock

Parameters
time_since_epoch - The time since the UNIX epoch. The precision of the CnxTimePoint will be the period of this CnxDuration
clock - The clock associated with this time point
locale - Whether this time point is in UTC time, local time, or some unknown time locale
Returns a CnxTimePoint representing the given time since the epoch

CnxDuration cnx_time_point_time_since_epoch(CnxTimePoint self)

Returns the time since the UNIX epoch of the given CnxTimePoint

Parameters
self - The CnxTimePoint to get the represented time from
Returns The time since the epoch represented by self, as a CnxDuration

CnxTimePoint cnx_time_point_min(CnxTimePoint self)

Returns the minimum possible CnxTimePoint with the same precision as the given one.

Parameters
self - The CnxTimePoint with the desired precision
Returns The minimum possible CnxTimePoint with the same precision as the given one

CnxTimePoint cnx_time_point_max(CnxTimePoint self)

Returns the maximum possible CnxTimePoint with the same precision as the given one.

Parameters
self - The CnxTimePoint with the desired precision
Returns The maximum possible CnxTimePoint with the same precision as the given one

CnxTimePoint cnx_time_point_cast(CnxTimePoint to_cast, CnxTimePoint new_precision)

Converts the first CnxTimePoint to the same precision as the second one.

Parameters
to_cast - The CnxTimePoint to convert the precision of
new_precision - The CnxTimePoint with the precision to convert to
Returns to_cast converted to the precision of new_precision

CnxTimePoint cnx_time_point_ceil(CnxTimePoint to_cast, CnxTimePoint new_precision)

Converts the first CnxTimePoint to the same precision as the second one, taking the ceiling of any fractional part in the result.

Parameters
to_cast - The CnxTimePoint to convert the precision of
new_precision - The CnxTimePoint with the precision to convert to
Returns to_cast converted to the precision of new_precision

CnxTimePoint cnx_time_point_floor(CnxTimePoint to_cast, CnxTimePoint new_precision)

Converts the first CnxTimePoint to the same precision as the second one, taking the floor of any fractional part in the result.

Parameters
to_cast - The CnxTimePoint to convert the precision of
new_precision - The CnxTimePoint with the precision to convert to
Returns to_cast converted to the precision of new_precision

CnxTimePoint cnx_time_point_round(CnxTimePoint to_cast, CnxTimePoint new_precision)

Converts the first CnxTimePoint to the same precision as the second one, rounding any fractional part in the result.

Parameters
to_cast - The CnxTimePoint to convert the precision of
new_precision - The CnxTimePoint with the precision to convert to
Returns to_cast converted to the precision of new_precision

time_t cnx_time_point_as_time_t(CnxTimePoint to_cast)

Converts the given CnxTimePoint to time_t

Parameters
to_cast - The CnxTimePoint to convert
Returns to_cast converted to time_t

CnxResult(tm)

Converts the given CnxTimePoint to tm

Returns to_cast converted to tm

CnxTimePoint cnx_time_point_from_time_t(time_t time)

Converts the given time_t to a CnxTimePoint in the system clock precision.

Parameters
time - The time_t to convert
Returns time converted to a CnxTimePoint

void cnx_time_point_increment(CnxTimePoint*restrict self)

Increments the given CnxTimePoint by one unit.

Parameters
self - The CnxTimePoint to increment

void cnx_time_point_decrement(CnxTimePoint*restrict self)

Decrements the given CnxTimePoint by one unit.

Parameters
self - The CnxTimePoint to decrement

CnxTimePoint cnx_time_point_add(CnxTimePoint lhs, CnxDuration rhs)

Adds the given CnxDuration to the given CnxTimePoint

Parameters
lhs - The CnxTimePoint to add to
rhs - The amount of time to add to lhs
Returns the result of the addition

CnxTimePoint cnx_time_point_subtract(CnxTimePoint lhs, CnxDuration rhs)

Subtracts the given CnxDuration from the given CnxTimePoint

Parameters
lhs - The CnxTimePoint to subtract from
rhs - The amount of time to subtract from lhs
Returns the result of the subtraction

CnxTimePoint cnx_time_point_add_time_point(CnxTimePoint lhs, CnxTimePoint rhs)

Adds the rhs CnxTimePoint to the lhs CnxTimePoint

Parameters
lhs - The CnxTimePoint to add to
rhs - The amount of time to add to lhs
Returns the result of the addition

CnxTimePoint cnx_time_point_subtract_time_point(CnxTimePoint lhs, CnxTimePoint rhs)

Subtracts the rhs CnxDuration from the lhs CnxTimePoint

Parameters
lhs - The CnxTimePoint to subtract from
rhs - The amount of time to subtract from lhs
Returns the result of the subtraction

CnxTimePoint cnx_time_point_add_scalar(CnxTimePoint lhs, i64 rhs)

Adds the given scalar value to the given CnxTimePoint as if it were a CnxTimePoint or CnxDuration in the same precision.

Parameters
lhs - The CnxTimePoint to add to
rhs - The amount of time to add to lhs
Returns the result of the addition

CnxTimePoint cnx_time_point_subtract_scalar(CnxTimePoint lhs, i64 rhs)

Subtracts the given scalar value from the given CnxTimePoint as if it were a CnxTimePoint or CnxDuration in the same precision.

Parameters
lhs - The CnxTimePoint to add to
rhs - The amount of time to add to lhs
Returns the result of the addition

bool cnx_time_point_equal(CnxTimePoint lhs, CnxTimePoint rhs)

Determines if the two CnxTimePoints are equivalent. Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns Whether the two CnxTimePoints are equivalent

bool cnx_time_point_not_equal(CnxTimePoint lhs, CnxTimePoint rhs)

Determines if the two CnxTimePoints are NOT equivalent. Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns Whether the two CnxTimePoints are NOT equivalent

bool cnx_time_point_less_than(CnxTimePoint lhs, CnxTimePoint rhs)

Determines if the left-hand-side CnxTimePoint is less than the right-hand-side Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns Whether lhs < rhs

bool cnx_time_point_less_than_or_equal(CnxTimePoint lhs, CnxTimePoint rhs)

Determines if the left-hand-side CnxTimePoint is less than or equal to the right-hand-side. Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns Whether lhs <= rhs

bool cnx_time_point_greater_than(CnxTimePoint lhs, CnxTimePoint rhs)

Determines if the left-hand-side CnxTimePoint is greater than the right-hand-side Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns Whether lhs > rhs

bool cnx_time_point_greater_than_or_equal(CnxTimePoint lhs, CnxTimePoint rhs)

Determines if the left-hand-side CnxTimePoint is greater than or equal to the right-hand-side. Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns Whether lhs >= rhs

CnxCompare cnx_time_point_compare(CnxTimePoint lhs, CnxTimePoint rhs)

Performs a three-way comparison of lhs to rhs, determining how lhs mathematically relates to rhs. Converts to the precision of the most precise of the two prior to comparison.

Parameters
lhs - The left-hand-side CnxTimePoint to compare
rhs - The right-hand-side CnxTimePoint to compare
Returns How lhs compares to rhs, as CnxCompare

CnxString cnx_time_point_format(const CnxFormat*restrict self, CnxFormatContext context)

Implements the allocator-unaware part of the CnxFormat trait for CnxTimePoint

Parameters
self - The CnxTimePoint to format, as its CnxFormat trait representation
context - The CnxFormatContext specifying how formatting should be done
Returns self formatted as a CnxString

CnxString cnx_time_point_format_with_allocator(const CnxFormat*restrict self, CnxFormatContext context, CnxAllocator allocator)

Implements the allocator-aware part of the CnxFormat trait for CnxTimePoint

Parameters
self - The CnxTimePoint 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

Variable documentation

CnxDuration time_since_epoch

The point in time, represented as a duration since the UNIX epoch.

const CnxClock* clock

The clock associated with this time point.