![]() |
Manual for OpenFLUID 2.1.11 |
Class for management of date and time information.
Class for management of date and time information. It includes arithmetics and comparisons operations.
Sources:
Example : creating a date
Example : adding time span to a date
Example : subtracting time span to a date
Example : getting difference in seconds between two dates
#include <core/DateTime.hpp>
Public Member Functions | |
| DateTime () | |
| DateTime (const DateTime &)=default | |
| DateTime (DateTime &&)=default | |
| DateTime (int Year, int Month, int Day, int Hour, int Minute, int Second) | |
| DateTime (RawTime_t SecondsSince0000) | |
| DateTime & | operator= (const DateTime &Other)=default |
| DateTime & | operator= (DateTime &&Other)=default |
| ~DateTime ()=default | |
| bool | set (int Year, int Month, int Day, int Hour, int Minute, int Second) |
| void | set (const RawTime_t &SecondsSince0000) |
| bool | setFromISOString (const std::string &DateTimeStr) |
| bool | setFromString (const std::string &DateTimeStr, const std::string &FormatStr) |
| int | getYear () const |
| int | getMonth () const |
| int | getDay () const |
| int | getHour () const |
| int | getMinute () const |
| int | getSecond () const |
| RawTime_t | getRawTime () const |
| std::string | getAsISOString () const |
| std::string | getAsString (const std::string &Format) const |
| std::string | getDateAsISOString () const |
| std::string | getTimeAsISOString () const |
| void | addSeconds (const RawTime_t &Seconds) |
| void | subtractSeconds (const RawTime_t &Seconds) |
| RawTime_t | diffInSeconds (const DateTime &DT) const |
| bool | isBetween (const DateTime &FirstDT, const DateTime &SecondDT) |
| bool | isStrictlyBetween (const DateTime &FirstDT, const DateTime &SecondDT) |
| bool | operator== (const DateTime &Right) const |
| bool | operator!= (const DateTime &Right) const |
| bool | operator> (const DateTime &Right) const |
| bool | operator>= (const DateTime &Right) const |
| bool | operator< (const DateTime &Right) const |
| bool | operator<= (const DateTime &Right) const |
| DateTime | operator+ (const RawTime_t &Seconds) const |
| DateTime | operator- (const RawTime_t &Seconds) const |
| bool | isSameDate (const DateTime &DT) const |
| bool | isSameTime (const DateTime &DT) const |
Static Public Member Functions | |
| static RawTime_t | Minute () |
| static RawTime_t | Minutes (int N) |
| static RawTime_t | Hour () |
| static RawTime_t | Hours (int N) |
| static RawTime_t | Day () |
| static RawTime_t | Days (int N) |
| static RawTime_t | Week () |
| static RawTime_t | Weeks (int N) |
| static bool | isLeapYear (int Year) |
| static int | getNumOfDaysInMonth (int Year, int Month) |
| static bool | isValidDateTime (int Year, int Month, int Day, int Hour, int Minute, int Second) |
| openfluid::core::DateTime::DateTime | ( | ) |
Default constructor
|
default |
Copy constructor
|
default |
Move constructor
| openfluid::core::DateTime::DateTime | ( | int | Year, |
| int | Month, | ||
| int | Day, | ||
| int | Hour, | ||
| int | Minute, | ||
| int | Second | ||
| ) |
Constructor from date details
| openfluid::core::DateTime::DateTime | ( | RawTime_t | SecondsSince0000 | ) |
Constructor
|
default |
Destructor
| void openfluid::core::DateTime::addSeconds | ( | const RawTime_t & | Seconds | ) |
Adds the given seconds to the current date and time
|
inlinestatic |
Returns the number of seconds for one day
|
inlinestatic |
Returns the number of seconds for N days
Returns the difference in seconds between the date-time and the given date-time (Self - Given)
| std::string openfluid::core::DateTime::getAsISOString | ( | ) | const |
Returns date-time as string, using format YYYT-MM-DD hh:mm:ss
| std::string openfluid::core::DateTime::getAsString | ( | const std::string & | Format | ) | const |
Returns date-time as string, using strftime() format string
| [in] | Format | strftime()-like format string |
| std::string openfluid::core::DateTime::getDateAsISOString | ( | ) | const |
Returns date as string, using format YYYY-MM-DD
|
inline |
Returns Day [1-31]
|
inline |
Returns Hour [0-23]
|
inline |
Returns Minute [0-59]
|
inline |
Retourns Month [1-12]
|
static |
Returns the number of days in the given month for the given year
| RawTime_t openfluid::core::DateTime::getRawTime | ( | ) | const |
Returns date-time in raw format (number of seconds since first day of 4713 BC)
|
inline |
Returns Second [0-59]
| std::string openfluid::core::DateTime::getTimeAsISOString | ( | ) | const |
Returns time as string, using format hh:mm:ss
|
inline |
Returns Year (4 digits)
|
inlinestatic |
Returns the number of seconds for one hour
|
inlinestatic |
Returns the number of seconds for N hours
Returns true if the date-time is between the two given date-time
|
static |
Returns true if the given year is a leap year
| bool openfluid::core::DateTime::isSameDate | ( | const DateTime & | DT | ) | const |
Returns true if the given date is the same, without comparing time parts
| bool openfluid::core::DateTime::isSameTime | ( | const DateTime & | DT | ) | const |
Returns true if the given time is the same, without comparing dates
| bool openfluid::core::DateTime::isStrictlyBetween | ( | const DateTime & | FirstDT, |
| const DateTime & | SecondDT | ||
| ) |
Returns true if the date-time is strictly between the two given date-time
|
static |
Returns true if the given date time is valid
|
inlinestatic |
Returns the number of seconds for one minute
|
inlinestatic |
Returns the number of seconds for N minutes
| bool openfluid::core::DateTime::operator!= | ( | const DateTime & | Right | ) | const |
Difference operator
| bool openfluid::core::DateTime::operator< | ( | const DateTime & | Right | ) | const |
Lower than operator
| bool openfluid::core::DateTime::operator<= | ( | const DateTime & | Right | ) | const |
Lower than or equal operator
| bool openfluid::core::DateTime::operator== | ( | const DateTime & | Right | ) | const |
Equal operator
| bool openfluid::core::DateTime::operator> | ( | const DateTime & | Right | ) | const |
Greater than operator
| bool openfluid::core::DateTime::operator>= | ( | const DateTime & | Right | ) | const |
Greater than or equal operator
| void openfluid::core::DateTime::set | ( | const RawTime_t & | SecondsSince0000 | ) |
Sets the date and time from the number of seconds since first day of 4713BC
| bool openfluid::core::DateTime::set | ( | int | Year, |
| int | Month, | ||
| int | Day, | ||
| int | Hour, | ||
| int | Minute, | ||
| int | Second | ||
| ) |
Sets the date and time from the parameters
| bool openfluid::core::DateTime::setFromISOString | ( | const std::string & | DateTimeStr | ) |
Sets the date and time from an ISO formatted string (YYYY-MM-DD hh:mm:ss)
| bool openfluid::core::DateTime::setFromString | ( | const std::string & | DateTimeStr, |
| const std::string & | FormatStr | ||
| ) |
Sets the date and time from a string using the given format
| void openfluid::core::DateTime::subtractSeconds | ( | const RawTime_t & | Seconds | ) |
Subtracts the given seconds from the current date and time
|
inlinestatic |
Returns the number of seconds for one week
|
inlinestatic |
Returns the number of seconds for N weeks
1.8.17