4#include "../Foundation/Compiler.h"
5#ifndef SC_EXPORT_LIBRARY_TIME
6#define SC_EXPORT_LIBRARY_TIME 0
8#define SC_TIME_EXPORT SC_COMPILER_LIBRARY_EXPORT(SC_EXPORT_LIBRARY_TIME)
10#include "../Foundation/PrimitiveTypes.h"
42 [[nodiscard]]
bool operator>(
const Nanoseconds other)
const {
return ns > other.ns; }
43 [[nodiscard]]
bool operator<(
const Nanoseconds other)
const {
return ns < other.ns; }
44 [[nodiscard]]
bool operator==(
const Nanoseconds other)
const {
return ns == other.ns; }
54 [[nodiscard]]
operator TimeMs()
const {
return {ms}; }
55 [[nodiscard]]
bool operator>(
const Milliseconds other)
const {
return ms > other.ms; }
56 [[nodiscard]]
bool operator<(
const Milliseconds other)
const {
return ms < other.ms; }
57 [[nodiscard]]
bool operator==(
const Milliseconds other)
const {
return ms == other.ms; }
67 [[nodiscard]]
bool operator>(
const Seconds other)
const {
return sec > other.sec; }
68 [[nodiscard]]
bool operator<(
const Seconds other)
const {
return sec < other.sec; }
69 [[nodiscard]]
bool operator==(
const Seconds other)
const {
return sec == other.sec; }
91 [[nodiscard]]
bool operator>(
const Relative other)
const {
return seconds > other.seconds; }
92 [[nodiscard]]
bool operator<(
const Relative other)
const {
return seconds < other.seconds; }
93 [[nodiscard]]
bool operator==(
const Relative other)
const {
return toNanoseconds() == other.toNanoseconds(); }
95 Seconds toSeconds()
const {
return Seconds(
static_cast<int64_t>(seconds + 0.5)); }
96 Nanoseconds toNanoseconds()
const {
return Nanoseconds(
static_cast<int64_t>(seconds * 1e9 + 0.5)); }
97 Milliseconds toMilliseconds()
const {
return Milliseconds(
static_cast<int64_t>(seconds * 1e3 + 0.5)); }
100 Relative(
double seconds) : seconds(seconds) {}
107inline Time::Nanoseconds
operator""_ns(
unsigned long long int ns) {
return Time::Nanoseconds(
static_cast<int64_t>(ns)); }
108inline Time::Milliseconds
operator""_ms(
unsigned long long int ms) {
return Time::Milliseconds(
static_cast<int64_t>(ms)); }
109inline Time::Seconds
operator""_sec(
unsigned long long int sec) {
return Time::Seconds(
static_cast<int64_t>(sec)); }
142 const char* getMonth()
const;
143 const char* getDay()
const;
144 bool isDaylightSaving =
false;
147 friend struct Internal;
unsigned short uint16_t
Platform independent (2) bytes unsigned int.
Definition PrimitiveTypes.h:28
unsigned char uint8_t
Platform independent (1) byte unsigned int.
Definition PrimitiveTypes.h:27
long long int64_t
Platform independent (8) bytes signed int.
Definition PrimitiveTypes.h:41
A vocabulary type representing a time interval in milliseconds since epoch.
Definition PrimitiveTypes.h:50
Holds information on a parsed absolute time from Absolute::parseLocal.
Definition Time.h:132
Absolute time as realtime or monotonically increasing clock.
Definition Time.h:116
Absolute offsetBy(Milliseconds other) const
Offset this absolute time with a relative time in milliseconds.
bool isLaterThanOrEqualTo(Absolute other) const
Check if this Absolute time is later or equal to another Absolute time.
bool isLaterThan(Absolute other) const
Check if this Absolute time is lather than another Absolute time.
Absolute(int64_t milliseconds)
Construct an Absolute from milliseconds since epoch.
Definition Time.h:126
bool parseUTC(ParseResult &result) const
Parses UTC time to a Parsed structure.
Absolute()=default
Construct an Absolute time equal to epoch.
Milliseconds subtractExact(Absolute other) const
Obtains the difference between this time and the other time.
bool parseLocal(ParseResult &result) const
Parses local time to a Parsed structure.
An high resolution time counter.
Definition Time.h:207
Milliseconds toMilliseconds() const
Converts to Milliseconds.
Relative subtractApproximate(HighResolutionCounter other) const
Subtracts another HighResolutionCounter from this one, returning an approximate Relative.
Relative getRelative() const
Converts to a Relative struct.
Nanoseconds toNanoseconds() const
Converts to Nanoseconds.
HighResolutionCounter offsetBy(Milliseconds ms) const
Returns a HighResolutionCounter offset by a given number of Milliseconds.
Seconds toSeconds() const
Converts to Seconds.
bool isLaterThanOrEqualTo(HighResolutionCounter other) const
Check if this HighResolutionCounter is later or equal to another HighResolutionCounter.
HighResolutionCounter & snap()
Sets HighResolutionCounter to current instant Example:
HighResolutionCounter subtractExact(HighResolutionCounter other) const
Subtracts another HighResolutionCounter from this one, returning a precise HighResolutionCounter.
Type-safe wrapper of uint64 used to represent milliseconds.
Definition Time.h:49
Represent monotonically increasing time (use Monotonic::now for current time)
Definition Time.h:183
int64_t getMonotonicMilliseconds() const
Return given time as monotonically incrementing milliseconds.
Definition Time.h:190
static Monotonic now()
Obtain time according to monotonic clock.
Type-safe wrapper of uint64 used to represent nanoseconds.
Definition Time.h:37
Represents a realtime clock in milliseconds since epoch (use Realtime::now for current time)
Definition Time.h:195
static Realtime now()
Obtain time according to realtime clock.
int64_t getMillisecondsSinceEpoch() const
Return given time as milliseconds since epoch.
Definition Time.h:202
Interval of time represented with 64 bit double precision float.
Definition Time.h:76
Relative(Milliseconds time)
Construct a Relative from milliseconds.
Definition Time.h:81
Relative(Seconds time)
Construct a Relative from seconds.
Definition Time.h:87
Relative()
how many seconds have elapsed in
Definition Time.h:78
Relative(Nanoseconds time)
Construct a Relative from nanoseconds.
Definition Time.h:84
Type-safe wrapper of uint64 used to represent seconds.
Definition Time.h:62