Class for management of date and time information.
More...
#include <core/DateTime.hpp>
|
| DateTime () |
|
| DateTime (int Year, int Month, int Day, int Hour, int Minute, int Second) |
|
| DateTime (RawTime_t SecondsSince0000) |
|
| ~DateTime () |
|
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 (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) |
|
DateTime & | operator= (const DateTime &Right) |
|
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 |
|
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
aDate.subtractSeconds(10);
Example : getting difference in seconds between two dates
Diff = SecondDate - FirstDate;
std::cout << "The difference between the two dates is greater than 60 days" << std::end;
else
std::cout << "The difference between the two dates is lesser than 60 days" << std::end;
◆ DateTime() [1/3]
openfluid::core::DateTime::DateTime |
( |
| ) |
|
◆ DateTime() [2/3]
openfluid::core::DateTime::DateTime |
( |
int |
Year, |
|
|
int |
Month, |
|
|
int |
Day, |
|
|
int |
Hour, |
|
|
int |
Minute, |
|
|
int |
Second |
|
) |
| |
◆ DateTime() [3/3]
openfluid::core::DateTime::DateTime |
( |
RawTime_t |
SecondsSince0000 | ) |
|
◆ ~DateTime()
openfluid::core::DateTime::~DateTime |
( |
| ) |
|
◆ addSeconds()
void openfluid::core::DateTime::addSeconds |
( |
const RawTime_t & |
Seconds | ) |
|
Adds the given seconds to the current date and time
◆ Day()
static RawTime_t openfluid::core::DateTime::Day |
( |
| ) |
|
|
inlinestatic |
Returns the number of seconds for one day
◆ Days()
static RawTime_t openfluid::core::DateTime::Days |
( |
int |
N | ) |
|
|
inlinestatic |
Returns the number of seconds for N days
◆ diffInSeconds()
Returns the difference in seconds between the date-time and the given date-time (Self - Given)
◆ getAsISOString()
std::string openfluid::core::DateTime::getAsISOString |
( |
| ) |
const |
Returns date-time as string, using format YYYT-MM-DD hh:mm:ss
- Returns
- a string
◆ getAsString()
std::string openfluid::core::DateTime::getAsString |
( |
std::string |
Format | ) |
const |
Returns date-time as string, using strftime() format string
- Parameters
-
[in] | Format | strftime()-like format string |
- Returns
- a string
◆ getDateAsISOString()
std::string openfluid::core::DateTime::getDateAsISOString |
( |
| ) |
const |
Returns date as string, using format YYYY-MM-DD
- Returns
- a string
◆ getDay()
int openfluid::core::DateTime::getDay |
( |
| ) |
const |
|
inline |
Returns Day [1-31]
- Returns
- an int
◆ getHour()
int openfluid::core::DateTime::getHour |
( |
| ) |
const |
|
inline |
Returns Hour [0-23]
- Returns
- an int
◆ getMinute()
int openfluid::core::DateTime::getMinute |
( |
| ) |
const |
|
inline |
Returns Minute [0-59]
- Returns
- an int
◆ getMonth()
int openfluid::core::DateTime::getMonth |
( |
| ) |
const |
|
inline |
Retourns Month [1-12]
- Returns
- an int
◆ getNumOfDaysInMonth()
static int openfluid::core::DateTime::getNumOfDaysInMonth |
( |
int |
Year, |
|
|
int |
Month |
|
) |
| |
|
static |
Returns the number of days in the given month for the given year
◆ getRawTime()
RawTime_t openfluid::core::DateTime::getRawTime |
( |
| ) |
const |
Returns date-time in raw format (number of seconds since first day of 4713 BC)
- Returns
- a rawtime_t
◆ getSecond()
int openfluid::core::DateTime::getSecond |
( |
| ) |
const |
|
inline |
Returns Second [0-59]
- Returns
- an int
◆ getTimeAsISOString()
std::string openfluid::core::DateTime::getTimeAsISOString |
( |
| ) |
const |
Returns time as string, using format hh:mm:ss
- Returns
- a string
◆ getYear()
int openfluid::core::DateTime::getYear |
( |
| ) |
const |
|
inline |
Returns Year (4 digits)
- Returns
- an int
◆ Hour()
static RawTime_t openfluid::core::DateTime::Hour |
( |
| ) |
|
|
inlinestatic |
Returns the number of seconds for one hour
◆ Hours()
static RawTime_t openfluid::core::DateTime::Hours |
( |
int |
N | ) |
|
|
inlinestatic |
Returns the number of seconds for N hours
◆ isBetween()
bool openfluid::core::DateTime::isBetween |
( |
const DateTime & |
FirstDT, |
|
|
const DateTime & |
SecondDT |
|
) |
| |
Returns true if the date-time is between the two given date-time
◆ isLeapYear()
static bool openfluid::core::DateTime::isLeapYear |
( |
int |
Year | ) |
|
|
static |
Returns true if the given year is a leap year
◆ isSameDate()
bool openfluid::core::DateTime::isSameDate |
( |
const DateTime & |
DT | ) |
const |
Returns true if the given date is the same, without comparing time parts
◆ isSameTime()
bool openfluid::core::DateTime::isSameTime |
( |
const DateTime & |
DT | ) |
const |
Returns true if the given time is the same, without comparing dates
◆ isStrictlyBetween()
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
◆ isValidDateTime()
static bool openfluid::core::DateTime::isValidDateTime |
( |
int |
Year, |
|
|
int |
Month, |
|
|
int |
Day, |
|
|
int |
Hour, |
|
|
int |
Minute, |
|
|
int |
Second |
|
) |
| |
|
static |
Returns true if the given date time is valid
◆ Minute()
static RawTime_t openfluid::core::DateTime::Minute |
( |
| ) |
|
|
inlinestatic |
Returns the number of seconds for one minute
◆ Minutes()
static RawTime_t openfluid::core::DateTime::Minutes |
( |
int |
N | ) |
|
|
inlinestatic |
Returns the number of seconds for N minutes
◆ operator!=()
bool openfluid::core::DateTime::operator!= |
( |
const DateTime & |
Right | ) |
const |
◆ operator+()
◆ operator-()
◆ operator<()
bool openfluid::core::DateTime::operator< |
( |
const DateTime & |
Right | ) |
const |
◆ operator<=()
bool openfluid::core::DateTime::operator<= |
( |
const DateTime & |
Right | ) |
const |
Lower than or equal operator
◆ operator=()
◆ operator==()
bool openfluid::core::DateTime::operator== |
( |
const DateTime & |
Right | ) |
const |
◆ operator>()
bool openfluid::core::DateTime::operator> |
( |
const DateTime & |
Right | ) |
const |
◆ operator>=()
bool openfluid::core::DateTime::operator>= |
( |
const DateTime & |
Right | ) |
const |
Greater than or equal operator
◆ set() [1/2]
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
◆ set() [2/2]
void openfluid::core::DateTime::set |
( |
const RawTime_t & |
SecondsSince0000 | ) |
|
Sets the date and time from the number of seconds since first day of 4713BC
◆ setFromISOString()
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)
◆ setFromString()
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
◆ subtractSeconds()
void openfluid::core::DateTime::subtractSeconds |
( |
const RawTime_t & |
Seconds | ) |
|
Subtracts the given seconds from the current date and time
◆ Week()
static RawTime_t openfluid::core::DateTime::Week |
( |
| ) |
|
|
inlinestatic |
Returns the number of seconds for one week
◆ Weeks()
static RawTime_t openfluid::core::DateTime::Weeks |
( |
int |
N | ) |
|
|
inlinestatic |
Returns the number of seconds for N weeks
The documentation for this class was generated from the following file: