|
Ocean
|
This class provides basic functionalities for date and time handling. More...
#include <DateTime.h>
Static Public Member Functions | |
| static double | timestamp () |
| Returns the seconds since 1970.01.01 00::00::00 to current UTC time. | |
| static long long | microseconds () |
| Returns the microseconds since 1970.01.01 00::00::00 to current UTC time. | |
| static std::string | string (const bool addMilliseconds=false) |
| Returns the string of the UTC date and time. | |
| static std::string | string (const double timestamp, const bool addMilliseconds=false) |
| Returns the string of a given unix timestamp. | |
| static std::string | stringDate (const char delimiter='.') |
| Returns the string of the UTC date. | |
| static std::string | stringDate (const double timestamp, const bool nameMonths=false) |
| Returns the string of a given unix timestamp. | |
| static std::string | stringTime (const bool addMilliseconds=false, const char delimiter='-') |
| Returns the string of the UTC time. | |
| static std::string | stringTime (const double timestamp, const bool addMilliseconds=false, const char delimiter='-') |
| Returns the string of a given unix timestamp. | |
| static double | localTimestamp () |
| Returns the seconds since 1970.01.01 00::00::00 to current local time. | |
| static long long | localMicroseconds () |
| Returns the microseconds since 1970.01.01 00::00::00 to current local time. | |
| static std::string | localString () |
| Returns the string of the local date and time suitable for a text/log output. | |
| static std::string | localStringForFile () |
| Returns the string of the local date and time suitable for a filename. | |
| static std::string | localStringDate (const char delimiter='.') |
| Returns the string of the local date. | |
| static double | date2timestamp (const unsigned int year, const unsigned int month, const unsigned int day, const unsigned int hour, const unsigned int minute, const unsigned int second, const unsigned int millisecond=0u) |
| Converts a date to the seconds since 1970.01.01 00:00:00. | |
| static void | timestamp2date (const double timestamp, unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second, unsigned int *millisecond=nullptr) |
| Converts a unix timestamp (the seconds since 1970.01.01 00:00:00) to a date. | |
| static std::string | seconds2string (const double totalSeconds, const bool addDescription, const bool addMilliseconds=false) |
| Converts value of seconds to a time string showing the hours, minutes and seconds. | |
| static std::string | localStringTime (const bool addMilliseconds=false, const char delimiter=':') |
| Returns the string of the local time. | |
| static unsigned int | isLeapYear (const unsigned int year) |
| Returns whether a given year is a leap year. | |
| static bool | isDateValid (const unsigned int year, const unsigned int month, const unsigned int day) |
| Returns whether a given date is a valid date (e.g., in no leap years the 29th February is an invalid date) | |
This class provides basic functionalities for date and time handling.
All functions are available for UTC and local time.
|
static |
Converts a date to the seconds since 1970.01.01 00:00:00.
| year | The year, with range [1970, 2037) |
| month | The month, with range [1, 12] |
| day | The day, with range [1, 31] |
| hour | The hour, with range [0, 23] |
| minute | The minute, with range [0, 59] |
| second | The second, with range [0, 59] |
| millisecond | The millisecond, with range [0, 999] |
|
static |
Returns whether a given date is a valid date (e.g., in no leap years the 29th February is an invalid date)
| year | The year of the date, with range [0, infinity) |
| month | The month of the date, with range [1, 12] |
| day | The day of the date, with range [1, 31] |
|
inlinestatic |
Returns whether a given year is a leap year.
| year | The year to check |
|
static |
Returns the microseconds since 1970.01.01 00::00::00 to current local time.
|
static |
Returns the string of the local date and time suitable for a text/log output.
The format of the resulting string is YYYY.MM.DD HH:MM:SS.
|
static |
Returns the string of the local date.
| delimiter | The delimiter to be used |
|
static |
Returns the string of the local date and time suitable for a filename.
The format of the resulting string is YYYY-MM-DD_HH-MM-SS.
|
static |
Returns the string of the local time.
The resulting string has the following format: HH:MM:SS, or HH:MM:SS:mmmm if the milliseconds are added.
| addMilliseconds | True, to add the milliseconds to the string |
| delimiter | The delimiter to be used |
|
static |
Returns the seconds since 1970.01.01 00::00::00 to current local time.
|
static |
Returns the microseconds since 1970.01.01 00::00::00 to current UTC time.
|
static |
Converts value of seconds to a time string showing the hours, minutes and seconds.
The resulting string has the following format: HH:MM:SS, or HH:MM:SS:mmmm if the milliseconds are added; or H hours, M minutes, S seconds or H hours, M minutes, S seconds, m milliseconds if the description is added.
| totalSeconds | The number of seconds to convert, with range [0, infinity) |
| addDescription | True, to add the description text to the string |
| addMilliseconds | True, to add the milliseconds to the string |
|
static |
Returns the string of the UTC date and time.
| addMilliseconds | True, to add the milliseconds to the string |
|
static |
Returns the string of a given unix timestamp.
| timestamp | The unix timestamp (seconds since 1970.01.01 00:00:00) to be converted, with range [0, infinity) |
| addMilliseconds | True, to add the milliseconds to the string |
|
static |
Returns the string of the UTC date.
| delimiter | The delimiter to be used |
|
static |
Returns the string of a given unix timestamp.
| timestamp | The unix timestamp (seconds since 1970.01.01 00:00:00) to be converted, with range [0, infinity) |
| nameMonths | True, to receive a date with named months; False, to receive a date with digits only (but with constant length) |
|
static |
Returns the string of the UTC time.
The resulting string has the following format: HH-MM-SS, or HH-MM-SS-mmmm if the milliseconds are added.
| addMilliseconds | True, to add the milliseconds to the string |
| delimiter | The delimiter to be used |
|
static |
Returns the string of a given unix timestamp.
The resulting string has the following format: HH-MM-SS, or HH-MM-SS-mmmm if the milliseconds are added.
| timestamp | The unix timestamp (seconds since 1970.01.01 00:00:00) to be converted, with range [0, infinity) |
| addMilliseconds | True, to add the milliseconds to the string |
| delimiter | The delimiter to be used |
|
static |
Returns the seconds since 1970.01.01 00::00::00 to current UTC time.
|
static |
Converts a unix timestamp (the seconds since 1970.01.01 00:00:00) to a date.
| timestamp | The unix timestamp to convert |
| year | The resulting year, with range [1970, 2037) |
| month | The resulting month, with range [1, 12] |
| day | The resulting date, with range [1, 31] |
| hour | The resulting hour, with range [0, 23] |
| minute | The resulting minute, with range [0, 59] |
| second | The resulting second, with range [0, 59] |
| millisecond | Optional resulting millisecond, with range [0, 999] |