API Documentation
|
Represents a timestamp with utilities for manipulation and conversion. More...
#include <Time.h>
Public Types | |
enum | Months { JANUARY = 1 , FEBRUARY , MARCH , APRIL , MAY , JUNE , JULY , AUGUST , SEPTEMBER , OCTOBER , NOVEMBER , DECEMBER } |
Enumerates the months of the year. More... | |
Public Member Functions | |
uint08 | daysConstant () const |
uint08 | getMilliseconds () const |
Gets the timestamp in milliseconds. | |
constexpr uint08 | getNanoSeconds () const |
Gets the timestamp in nanoseconds. | |
uint01 | hour (bool is_local_time) const |
Retrieves the hour component of the timestamp. | |
fltp08 | julianDay (bool is_local_time) const |
uint08 | leapYearConstant () const |
uint02 | millisecond () const |
uint01 | minute (bool is_local_time) const |
uint02 | month (bool is_local_time) const |
Retrieves the month component of the timestamp. | |
uint02 | monthDay (bool is_local_time) const |
uint08 | monthsConstant () const |
bool | operator!= (const Time &time) const |
bool | operator< (const Time &time) const |
bool | operator<= (const Time &time) const |
bool | operator== (const Time &time) const |
bool | operator> (const Time &time) const |
bool | operator>= (const Time &time) const |
uint01 | second (bool is_local_time) const |
void | setDayOfYear (const uint02 &day, bool is_local_time) |
void | setHour (const uint01 &hour, bool is_local_time) |
void | setMillisecond (const uint02 &millisecond) |
void | setMinute (const uint01 &minute, bool is_local_time) |
void | setMonth (const uint01 &month, bool is_local_time) |
void | setMonthDay (const uint01 &day, bool is_local_time) |
void | setSecond (const uint01 &second, bool is_local_time) |
void | setTime (const uint08 &time) |
Sets the internal timestamp. | |
void | setTimeFromString (const String &time_string, bool is_local_time, const String &format_string) |
Sets the time by converting the timestamp from a string representation. https://ndevr.org/time-patterns/. | |
void | setYear (const uint02 &year, bool is_local_time) |
constexpr | Time () |
Default constructor initializing an invalid timestamp. | |
Time (const char *time_string, bool is_local_time, const String &format_string) | |
Time (const String &time_string, bool is_local_time, const String &format_string) | |
Constructs a Time from a string representation. https://ndevr.org/time-patterns/. | |
constexpr | Time (const uint08 &time) |
Constructor initializing the timestamp with a specific value. | |
Time (uint04 year, uint04 month, uint04 day, uint04 hour=0, uint04 minute=0, uint04 second=0, bool is_local_time=false) | |
Constructs a Time object using date and time components. | |
String | toString (bool get_local_time, const String &format_string) const |
Converts the timestamp to a string representation. https://ndevr.org/time-patterns/. | |
uint08 | unixTime () const |
Converts the timestamp to a UNIX time representation. | |
uint02 | year (bool is_local_time) const |
Retrieves the year component of the timestamp. | |
uint02 | yearDay (bool is_local_time) const |
Static Public Member Functions | |
static void | SetClockErrorCallback (const std::function< void(const Exception &error)> &function) |
static void | SetMakeLocalFromUTCFunction (const std::function< uint08(const tm &tm)> &function) |
static void | SetMakeUTCFromLocalFunction (const std::function< uint08(const tm &tm)> &function) |
static void | SetSystemTime (const Time &time) |
Sets the application's system clock to a specified Time . Note: Does not affect OS Time. | |
static Time | SystemTime () |
Retrieves the current system time. | |
Static Public Attributes | |
static constexpr uint08 | DAY = HOUR * 24 |
static constexpr uint08 | HOUR = MINUTE * 60 |
static constexpr uint08 | LEAP_YEAR = DAY * 366 |
static constexpr uint08 | MICROSECOND = 1000 * NANOSECOND |
static constexpr uint08 | MILLISECOND = 1000000 |
static constexpr uint08 | MINUTE = SECOND * 60 |
static constexpr uint08 | NANOSECOND = 1 |
static constexpr uint08 | SECOND = 1000000000 |
static constexpr uint08 | WEEK = DAY * 7 |
static constexpr uint08 | YEAR = DAY * 365 |
Represents a timestamp with utilities for manipulation and conversion.
The Time
class provides a framework for working with timestamps. It supports various time operations such as getting and setting components (year, month, day, hour, etc.), formatting, and conversions between time zones.
This class is designed for flexibility, making it suitable for a variety of applications, including scheduling, logging, and time-based calculations.
enum Months |
|
inlineconstexpr |
Default constructor initializing an invalid timestamp.
Constructor initializing the timestamp with a specific value.
time | Timestamp in nanoseconds. |
Time | ( | uint04 | year, |
uint04 | month, | ||
uint04 | day, | ||
uint04 | hour = 0, | ||
uint04 | minute = 0, | ||
uint04 | second = 0, | ||
bool | is_local_time = false ) |
Constructs a Time
object using date and time components.
year | Year component. |
month | Month component (1-12). |
day | Day of the month. |
hour | Hour of the day (default is 0). |
minute | Minute of the hour (default is 0). |
second | Second of the minute (default is 0). |
is_local_time | Indicates whether the time is local or UTC. |
Constructs a Time from a string representation. https://ndevr.org/time-patterns/.
time_string | The string to convert to a time |
is_local_time | Whether to convert to local time. |
format_string | The format for the string representation. |
|
nodiscard |
|
inlinenodiscard |
Gets the timestamp in milliseconds.
|
inlinenodiscardconstexpr |
Gets the timestamp in nanoseconds.
uint01 hour | ( | bool | is_local_time | ) | const |
Retrieves the hour component of the timestamp.
is_local_time | Indicates whether the time is local or UTC. |
fltp08 julianDay | ( | bool | is_local_time | ) | const |
|
nodiscard |
uint02 millisecond | ( | ) | const |
uint01 minute | ( | bool | is_local_time | ) | const |
uint02 month | ( | bool | is_local_time | ) | const |
Retrieves the month component of the timestamp.
is_local_time | Indicates whether the time is local or UTC. |
uint02 monthDay | ( | bool | is_local_time | ) | const |
|
nodiscard |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
uint01 second | ( | bool | is_local_time | ) | const |
|
static |
void setDayOfYear | ( | const uint02 & | day, |
bool | is_local_time ) |
void setHour | ( | const uint01 & | hour, |
bool | is_local_time ) |
|
static |
|
static |
void setMillisecond | ( | const uint02 & | millisecond | ) |
void setMinute | ( | const uint01 & | minute, |
bool | is_local_time ) |
void setMonth | ( | const uint01 & | month, |
bool | is_local_time ) |
void setMonthDay | ( | const uint01 & | day, |
bool | is_local_time ) |
void setSecond | ( | const uint01 & | second, |
bool | is_local_time ) |
|
static |
void setTime | ( | const uint08 & | time | ) |
Sets the internal timestamp.
time | Timestamp in nanoseconds. |
void setTimeFromString | ( | const String & | time_string, |
bool | is_local_time, | ||
const String & | format_string ) |
Sets the time by converting the timestamp from a string representation. https://ndevr.org/time-patterns/.
time_string | The string to convert to a time |
is_local_time | Whether to convert to local time. |
format_string | The format for the string representation. |
void setYear | ( | const uint02 & | year, |
bool | is_local_time ) |
|
static |
Retrieves the current system time.
Time
object. Converts the timestamp to a string representation. https://ndevr.org/time-patterns/.
get_local_time | Whether to convert to local time. |
format_string | The format for the string representation. |
uint08 unixTime | ( | ) | const |
Converts the timestamp to a UNIX time representation.
uint02 year | ( | bool | is_local_time | ) | const |
Retrieves the year component of the timestamp.
is_local_time | Indicates whether the time is local or UTC. |
uint02 yearDay | ( | bool | is_local_time | ) | const |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |