Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::Time::Absolute Struct Reference

Absolute time represented with milliseconds since epoch. More...

#include <Time.h>

Classes

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

Public Member Functions

 Absolute (int64_t millisecondsSinceEpoch)
 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...
 
Relative subtract (Absolute other)
 Obtain the Relative by subtracting this Absolute with another one. More...
 
int64_t getMillisecondsSinceEpoch () const
 Return given time as milliseconds since epoch. More...
 

Static Public Member Functions

static Absolute now ()
 Obtain Absolute representing current time. More...
 

Detailed Description

Absolute time represented with milliseconds since epoch.

Constructor & Destructor Documentation

◆ Absolute()

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

Construct an Absolute from milliseconds since epoch.

Parameters
millisecondsSinceEpochNumber of milliseconds since epoch

Member Function Documentation

◆ getMillisecondsSinceEpoch()

int64_t SC::Time::Absolute::getMillisecondsSinceEpoch ( ) const
inline

Return given time as milliseconds since epoch.

Returns
Time in milliseconds since epoch

◆ now()

static Absolute SC::Time::Absolute::now ( )
static

Obtain Absolute representing current time.

Returns
An Absolute representing current time

◆ 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
static Absolute now()
Obtain Absolute representing current time.
bool parseLocal(ParseResult &result) const
Parses local time to a Parsed structure.

◆ 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

◆ subtract()

Relative SC::Time::Absolute::subtract ( Absolute  other)

Obtain the Relative by subtracting this Absolute with another one.

Parameters
otherAnother Absolute to be subtracted
Returns
A Relative representing the time interval between the two Absolute

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