Sane C++ Libraries
C++ Platform Abstraction Libraries
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. More...
 
 Absolute (int64_t milliseconds)
 Construct an Absolute from milliseconds since epoch. More...
 
bool parseLocal (ParseResult &result) const
 Parses local time to a Parsed structure. More...
 
bool parseUTC (ParseResult &result) const
 Parses UTC time to a Parsed structure. More...
 
bool isLaterThanOrEqualTo (Absolute other) const
 Check if this Absolute time is later or equal to another Absolute time. More...
 
bool isLaterThan (Absolute other) const
 Check if this Absolute time is lather than another Absolute time. More...
 
Milliseconds subtractExact (Absolute other) const
 Obtains the difference between this time and the other time. More...
 
Absolute offsetBy (Milliseconds other) const
 Offset this absolute time with a relative time in milliseconds. More...
 

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

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

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

Offset this absolute time with a relative time in milliseconds.

◆ parseLocal()

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

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(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");
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition: Testing.h:113
bool parseLocal(ParseResult &result) const
Parses local time to a Parsed structure.
static Realtime now()
Obtain time according to realtime clock.

◆ parseUTC()

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

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

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: