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 | |
constexpr | Time () |
Default constructor initializing an invalid timestamp. | |
constexpr | Time (const uint08 &time) |
Constructor initializing the timestamp with a specific value. | |
NDEVR_BASE_API | 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. | |
NDEVR_BASE_API | 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/. | |
NDEVR_BASE_API | Time (const char *time_string, bool is_local_time, const String &format_string) |
NDEVR_BASE_API void | setTime (const uint08 &time) |
Sets the internal timestamp. | |
NDEVR_BASE_API String | toString (bool get_local_time, const String &format_string) const |
Converts the timestamp to a string representation. https://ndevr.org/time-patterns/. | |
NDEVR_BASE_API void | setTimeFromString (const String &time_string, bool is_local_time, const String &format_string) |
Converts the timestamp from a string representation. https://ndevr.org/time-patterns/. | |
NDEVR_BASE_API void | setHour (const uint01 &hour, bool is_local_time) |
NDEVR_BASE_API void | setMinute (const uint01 &minute, bool is_local_time) |
NDEVR_BASE_API void | setSecond (const uint01 &second, bool is_local_time) |
NDEVR_BASE_API void | setMillisecond (const uint02 &millisecond) |
NDEVR_BASE_API void | setYear (const uint02 &year, bool is_local_time) |
NDEVR_BASE_API void | setMonth (const uint01 &month, bool is_local_time) |
NDEVR_BASE_API void | setMonthDay (const uint01 &day, bool is_local_time) |
NDEVR_BASE_API void | setDayOfYear (const uint02 &day, bool is_local_time) |
NDEVR_BASE_API fltp08 | julianDay (bool is_local_time) const |
NDEVR_BASE_API uint02 | year (bool is_local_time) const |
Retrieves the year component of the timestamp. | |
NDEVR_BASE_API uint02 | month (bool is_local_time) const |
Retrieves the month component of the timestamp. | |
NDEVR_BASE_API uint02 | monthDay (bool is_local_time) const |
NDEVR_BASE_API uint02 | yearDay (bool is_local_time) const |
NDEVR_BASE_API uint01 | hour (bool is_local_time) const |
Retrieves the hour component of the timestamp. | |
NDEVR_BASE_API uint01 | minute (bool is_local_time) const |
NDEVR_BASE_API uint01 | second (bool is_local_time) const |
NDEVR_BASE_API uint02 | millisecond () const |
constexpr uint08 | getNanoSeconds () const |
Gets the timestamp in nanoseconds. | |
uint08 | getMilliseconds () const |
Gets the timestamp in milliseconds. | |
NDEVR_BASE_API uint08 | unixTime () const |
Converts the timestamp to a UNIX time representation. | |
NDEVR_BASE_API uint08 | leapYearConstant () const |
NDEVR_BASE_API uint08 | daysConstant () const |
NDEVR_BASE_API 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 |
Static Public Member Functions | |
static NDEVR_BASE_API Time | SystemTime () |
Retrieves the current system time. | |
static NDEVR_BASE_API void | SetSystemTime (const Time &time) |
Sets the application's system clock to a specified Time . Note: Does not affect OS Time. | |
static NDEVR_BASE_API void | SetMakeUTCFromLocalFunction (const std::function< uint08(const tm &tm)> &function) |
static NDEVR_BASE_API void | SetMakeLocalFromUTCFunction (const std::function< uint08(const tm &tm)> &function) |
static NDEVR_BASE_API void | SetClockErrorCallback (const std::function< void(const Exception &error)> &function) |
Static Public Attributes | |
static constexpr uint08 | NANOSECOND = 1 |
static constexpr uint08 | MICROSECOND = 1000 * NANOSECOND |
static constexpr uint08 | MILLISECOND = 1000000 |
static constexpr uint08 | SECOND = 1000000000 |
static constexpr uint08 | MINUTE = SECOND * 60 |
static constexpr uint08 | HOUR = MINUTE * 60 |
static constexpr uint08 | DAY = HOUR * 24 |
static constexpr uint08 | WEEK = DAY * 7 |
static constexpr uint08 | YEAR = DAY * 365 |
static constexpr uint08 | LEAP_YEAR = DAY * 366 |
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/.
get_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 ) |
Converts the timestamp from 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. |
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 |