Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::Time::Absolute Struct Reference

Absolute time as realtime or monotonically increasing clock. More...

#include <Time.h>

Inheritance diagram for SC::Time::Absolute:
SC::Time::Monotonic SC::Time::Realtime

Classes

struct  ParseResult
 Holds information on a parsed absolute time from Absolute::parseLocal. More...
 

Public Member Functions

 Absolute ()
 Construct an Absolute time equal to epoch.
 
 Absolute (int64_t milliseconds)
 Construct an Absolute from milliseconds since epoch.
 
bool parseLocal (ParseResult &result) const
 Parses local time to a Parsed structure.
 
bool parseUTC (ParseResult &result) const
 Parses UTC time to a Parsed structure.
 
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.
 
Milliseconds subtractExact (Absolute other) const
 Obtains the difference between this time and the other time.
 
Absolute offsetBy (Milliseconds other) const
 Offset this absolute time with a relative time in milliseconds.
 

Protected Attributes

int64_t milliseconds
 

Detailed Description

Absolute time as realtime or monotonically increasing clock.

See also
Monotonic
Realtime

Constructor & Destructor Documentation

◆ Absolute() [1/2]

SC::Time::Absolute::Absolute ( )
inline

Construct an Absolute time equal to epoch.

◆ Absolute() [2/2]

SC::Time::Absolute::Absolute ( int64_t milliseconds)
inline

Construct an Absolute from milliseconds since epoch.

Parameters
millisecondsNumber of milliseconds since epoch

Member Function Documentation

◆ isLaterThan()

bool SC::Time::Absolute::isLaterThan ( Absolute other) const
nodiscard

Check if this Absolute time is lather than another Absolute time.

Note
Comparing Absolute times obtained with different clock sources (monotonic/realtime) is meaningless

◆ isLaterThanOrEqualTo()

bool SC::Time::Absolute::isLaterThanOrEqualTo ( Absolute other) const
nodiscard

Check if this Absolute time is later or equal to another Absolute time.

Note
Comparing Absolute times obtained with different clock sources (monotonic/realtime) is meaningless

◆ offsetBy()

Absolute SC::Time::Absolute::offsetBy ( Milliseconds other) const
nodiscard

Offset this absolute time with a relative time in milliseconds.

◆ parseLocal()

bool SC::Time::Absolute::parseLocal ( ParseResult & result) const
nodiscard

Parses local time to a Parsed structure.

Parameters
[out]resultThe Parsed structure holding current date / time
Returns
true if time has been parsed successfully
Example:
Time::Absolute::ParseResult local;
SC_TEST_EXPECT(Time::Realtime::now().parseLocal(local));
SC_TEST_EXPECT(local.year > 2022);
report.console.print("{} {:02}/{:02}/{} {:02}:{:02}:{:02} {}", local.getDay(), local.dayOfMonth, local.getMonth(),
local.year, local.hour, local.minutes, local.seconds,
local.isDaylightSaving ? "DAYLIGHT SAVING" : "NO DAYLIGHT SAVING");

◆ parseUTC()

bool SC::Time::Absolute::parseUTC ( ParseResult & result) const
nodiscard

Parses UTC time to a Parsed structure.

Parameters
[out]resultThe Parsed structure holding current date / time
Returns
true if time has been parsed successfully

◆ subtractExact()

Milliseconds SC::Time::Absolute::subtractExact ( Absolute other) const
nodiscard

Obtains the difference between this time and the other time.

Note
Subtracting Absolute times obtained with different clock sources (monotonic/realtime) is meaningless

The documentation for this struct was generated from the following file: