include/Cnx/time/Clock.h file

This module provides methods for operating with system clocks.

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.

Enums

enum CnxClockResolution { CNX_CLOCK_NANOSECONDS, CNX_CLOCK_MICROSECONDS, CNX_CLOCK_MILLISECONDS, CNX_CLOCK_SECONDS }
CnxClockResolution lists the valid resolutions for CnxClock compatible clocks

Typedefs

using CnxClockResolution = enum CnxClockResolution
CnxClockResolution lists the valid resolutions for CnxClock compatible clocks

Functions

CnxTimePoint cnx_clock_now(const CnxClock*restrict self)
Returns a CnxTimePoint corresponding to the current time on the given clock.
CnxTimePoint cnx_clock_min_time_point(const CnxClock*restrict self)
Returns the minimum possible CnxTimePoint able to be associated with the given clock.
CnxTimePoint cnx_clock_max_time_point(const CnxClock*restrict self)
Returns the maximum possible CnxTimePoint able to be associated with the given clock.
CnxClockResolution cnx_clock_resolution(const CnxClock*restrict self)
Returns the resolution of the given clock.
CnxRatio cnx_clock_resolution_as_ratio(const CnxClock*restrict self)
Returns the resolution of the given clock.
CnxTimePointLocale cnx_clock_locale(const CnxClock*restrict self)
Returns the locale associated with the given clock.
CnxFormatContext cnx_clock_is_specifier_valid(const CnxFormat*restrict self, CnxStringView specifier)
Implementation of CnxFormat.is_specifier_valid for CnxClock
CnxString cnx_clock_format(const CnxFormat*restrict self, CnxFormatContext context)
Implements the allocator un-aware portion of the CnxFormat trait for all CnxClocks.
CnxString cnx_clock_format_with_allocator(const CnxFormat*restrict self, CnxFormatContext context, CnxAllocator allocator)
Implements the allocator aware portion of the CnxFormat trait for all CnxClocks.
static ImplTraitFor(CnxFormat, CnxClock, cnx_clock_is_specifier_valid, cnx_clock_format, cnx_clock_format_with_allocator)
Implements the CnxFormat trait for CnxClock
CnxTimePoint cnx_system_clock_now(void)
Returns a CnxTimePoint corresponding to the current time on the system clock.
CnxTimePoint cnx_system_clock_min_time_point(void)
Returns the minimum possible CnxTimePoint able to be associated with the system clock.
CnxTimePoint cnx_system_clock_max_time_point(void)
Returns the maximum possible CnxTimePoint able to be associated with the system clock.
CnxClockResolution cnx_system_clock_resolution(void)
Returns the resolution of the system clock.
CnxRatio cnx_system_clock_resolution_as_ratio(void)
Returns the resolution of the system clock.
CnxTimePointLocale cnx_system_clock_locale(void)
Returns the locale of the system clock.
CnxTimePoint cnx_steady_clock_now(void)
Returns a CnxTimePoint corresponding to the current time on the steady clock.
CnxTimePoint cnx_steady_clock_min_time_point(void)
Returns the minimum possible CnxTimePoint able to be associated with the steady clock.
CnxTimePoint cnx_steady_clock_max_time_point(void)
Returns the maximum possible CnxTimePoint able to be associated with the steady clock.
CnxClockResolution cnx_steady_clock_resolution(void)
Returns the resolution of the steady clock.
CnxRatio cnx_steady_clock_resolution_as_ratio(void)
Returns the resolution of the steady clock.
CnxTimePointLocale cnx_steady_clock_locale(void)
Returns the locale of the steady clock.
CnxTimePoint cnx_high_resolution_clock_now(void)
Returns a CnxTimePoint corresponding to the current time on the high resolution clock.
CnxTimePoint cnx_high_resolution_clock_min_time_point(void)
Returns the minimum possible CnxTimePoint able to be associated with the high resolution clock.
CnxTimePoint cnx_high_resolution_clock_max_time_point(void)
Returns the maximum possible CnxTimePoint able to be associated with the high resolution clock.
CnxClockResolution cnx_high_resolution_clock_resolution(void)
Returns the resolution of the high resolution clock.
CnxRatio cnx_high_resolution_clock_resolution_as_ratio(void)
Returns the resolution of the high resolution clock.
CnxTimePointLocale cnx_high_resolution_clock_locale(void)
Returns the locale of the high resolution clock.
CnxTimePoint cnx_utc_clock_now(void)
Returns a CnxTimePoint corresponding to the current time on the UTC clock.
CnxTimePoint cnx_utc_clock_min_time_point(void)
Returns the minimum possible CnxTimePoint able to be associated with the UTC clock.
CnxTimePoint cnx_utc_clock_max_time_point(void)
Returns the maximum possible CnxTimePoint able to be associated with the UTC clock.
CnxClockResolution cnx_utc_clock_resolution(void)
Returns the resolution of the UTC clock.
CnxRatio cnx_utc_clock_resolution_as_ratio(void)
Returns the resolution of the UTC clock.
CnxTimePointLocale cnx_utc_clock_locale(void)
Returns the locale of the UTC clock.
CnxTimePoint cnx_local_clock_now(void)
Returns a CnxTimePoint corresponding to the current time on the local clock.
CnxTimePoint cnx_local_clock_min_time_point(void)
Returns the minimum possible CnxTimePoint able to be associated with the local clock.
CnxTimePoint cnx_local_clock_max_time_point(void)
Returns the maximum possible CnxTimePoint able to be associated with the local clock.
CnxClockResolution cnx_local_clock_resolution(void)
Returns the resolution of the local clock.
CnxRatio cnx_local_clock_resolution_as_ratio(void)
Returns the resolution of the local clock.
CnxTimePointLocale cnx_local_clock_locale(void)
Returns the locale of the local clock.
CnxTimePoint cnx_convert_utc_to_local_time(CnxTimePoint utc)
Converts the given CnxTimePoint in UTC time to a CnxTimePoint in local time.
CnxTimePoint cnx_convert_local_time_to_utc(CnxTimePoint local_time)
Converts the given CnxTimePoint in local time to a CnxTimePoint in UTC time.

Variables

static let cnx_system_clock
The system clock.
static let cnx_steady_clock
The monotonic clock.
static let cnx_high_resolution_clock
The high resolution clock This will be equivalent to cnx_system_clock if CNX_NO_MONOTONIC_CLOCK is true (in which case a monotonic clock is not supported on the being-compiled-for platform). Otherwise, it will be a monotonic clock equivalent to cnx_steady_clock
static let cnx_utc_clock
The UTC clock.
static let cnx_local_clock
The local time clock.

Defines

#define CNX_NO_MONOTONIC_CLOCK
If CNX_NO_MONOTONIC_CLOCK is true, then either Cnx doesn't support a monotonic clock on the being-compiled-for-platform, the being-compiled-for platform itself doesn't, or both, and cnx_steady_clock and related functions are not available.

Function documentation

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

Implementation of CnxFormat.is_specifier_valid for CnxClock

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