include/Cnx/time/TimePoint.h file

CnxTimePoint provides functionality for working with specific points in time.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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.
CnxFormatContext cnx_time_point_is_specifier_valid(const CnxFormat*restrict self, CnxStringView specifier)
Implementation of CnxFormat.is_specifier_valid for CnxTimePoint
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

Function documentation

CnxFormatContext cnx_time_point_is_specifier_valid(const CnxFormat*restrict self, CnxStringView specifier)

Implementation of CnxFormat.is_specifier_valid for CnxTimePoint

Parameters
self - The CnxTimePoint to format as a CnxFormat trait object
specifier - The CnxStringView viewing the format specifier to validate
Returns The CnxFormatContext indicating whether specifier was valid and storing the state holding the format settings and necessary info to format the CnxTimePoint