cGetDayInfo
constexpr void cGetDayInfo(int year, int month, int day, int& dayOfYear, int& dayOfWeek);
Returns one-based day-of-year and weekday, with Sunday=1 and Saturday=7.
System & concurrency
Calendar conversion, Unix timestamps, nanosecond timestamps, and the cosmic time scale.
#include <mc/time.h>Unix calendar conversions use the process’s local time zone. Invalid dates and nonexistent local times throw CError; repeated local times use the platform’s automatic choice.
Cosmic time is an exact count of seconds since January 1 of year −13,700,000,000 in the proleptic Gregorian calendar. It includes astronomical year zero, with no time zones or leap seconds.
inline constexpr int64_t CTimeEpochYear = -13700000000LL;
constexpr void cGetDayInfo(int year, int month, int day, int& dayOfYear, int& dayOfWeek);
Returns one-based day-of-year and weekday, with Sunday=1 and Saturday=7.
constexpr void cDayOfYear(uint64_t year, int dayOfYear, int& month, int& day);
Converts a one-based day-of-year into month and day outputs for the supplied year, accounting for leap years. Invalid day numbers throw CError.
constexpr uint64_t cMakeTime(int64_t year, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0);
Constructs seconds on the cosmic calendar timeline.
constexpr void cUnmakeTime(uint64_t t, int64_t& year, int& month, int& day, int& hour, int& min, int& sec);
Splits cosmic seconds into calendar fields.
inline double cEpochMake(int year, int month = 1, int day = 1, int hour = 0, int min = 0, double seconds = 0.0);
Constructs a Unix timestamp in seconds from local calendar fields.
inline uint64_t cMakeNano(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t min, uint32_t sec, uint64_t nsec = 0);
Constructs Unix nanoseconds from local calendar fields and a nanosecond fraction.
inline void cEpochUnmakeSeconds(double t, int& year, int& month, int& day, int& hour, int& min, int& sec);
inline void cEpochUnmakeSeconds(double t, int& year, int& month, int& day, int& dayOfWeek, int& hour, int& min, int& sec);
Splits Unix seconds into local calendar fields, flooring fractional seconds.
inline void cEpochUnmakeNano(uint64_t t, int& year, int& month, int& day, int& hour, int& min, int& sec);
inline void cEpochUnmakeNano(uint64_t t, int& year, int& month, int& day, int& dayOfWeek, int& hour, int& min, int& sec);
Splits Unix nanoseconds into local calendar fields, discarding subsecond precision.
inline void cEpochUnmake(double t, int& year, int& month, int& day, int& hour, int& min, int& sec);
inline void cEpochUnmake(double t, int& year, int& month, int& day, int& dayOfWeek, int& hour, int& min, int& sec);
inline void cEpochUnmake(uint64_t t, int& year, int& month, int& day, int& hour, int& min, int& sec);
inline void cEpochUnmake(uint64_t t, int& year, int& month, int& day, int& dayOfWeek, int& hour, int& min, int& sec);
template<std::integral T> requires (!std::same_as<T, uint64_t> && !std::same_as<T, bool>) inline void cEpochUnmake(T t, int& year, int& month, int& day, int& hour, int& min, int& sec);
template<std::integral T> requires (!std::same_as<T, uint64_t> && !std::same_as<T, bool>) inline void cEpochUnmake(T t, int& year, int& month, int& day, int& dayOfWeek, int& hour, int& min, int& sec);
Compatibility overloads: floating-point input is seconds; integral input is nanoseconds.
Formats Unix seconds in the local time zone.
Formats Unix nanoseconds in the local time zone.
Formats the current wall-clock time in the local time zone. The default format includes the date, hour, and minute.
Parses local calendar text and returns Unix nanoseconds.