Auxililary class to get date and time.
More...
#include <JDate.hh>
|
static bool | isISO8601 (const std::string &datestr) |
| Function to check ISO-8601 conformity of string-formatted date and time. More...
|
|
Auxililary class to get date and time.
Definition at line 96 of file JSystem/JDate.hh.
JSYSTEM::JDateAndTime::JDateAndTime |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 100 of file JSystem/JDate.hh.
void set() const
Set to actual time.
JSYSTEM::JDateAndTime::JDateAndTime |
( |
const time_t |
t1 | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 111 of file JSystem/JDate.hh.
void set() const
Set to actual time.
tm* JSYSTEM::JDateAndTime::operator-> |
( |
| ) |
|
|
inline |
Smart pointer.
- Returns
- pointer to time structure
Definition at line 122 of file JSystem/JDate.hh.
const tm* JSYSTEM::JDateAndTime::operator-> |
( |
| ) |
const |
|
inline |
Smart pointer.
- Returns
- pointer to time structure
Definition at line 133 of file JSystem/JDate.hh.
int JSYSTEM::JDateAndTime::getSeconds |
( |
| ) |
const |
|
inline |
int JSYSTEM::JDateAndTime::getMinutes |
( |
| ) |
const |
|
inline |
int JSYSTEM::JDateAndTime::getHour |
( |
| ) |
const |
|
inline |
int JSYSTEM::JDateAndTime::getDay |
( |
| ) |
const |
|
inline |
int JSYSTEM::JDateAndTime::getMonth |
( |
| ) |
const |
|
inline |
int JSYSTEM::JDateAndTime::getYear |
( |
| ) |
const |
|
inline |
JSYSTEM::JDateAndTime::operator std::string |
( |
| ) |
const |
|
inline |
Type conversion operator.
- Returns
- ASCII formatted date and time
Definition at line 151 of file JSystem/JDate.hh.
std::string toString(const JDateAndTimeFormat option=ISO8601) const
Get ASCII formatted date and time.
static bool JSYSTEM::JDateAndTime::isISO8601 |
( |
const std::string & |
datestr | ) |
|
|
inlinestatic |
Function to check ISO-8601 conformity of string-formatted date and time.
- Parameters
-
datestr | string-formatted date and time |
- Returns
- true if date and time are ISO-8601-conform; else false
Definition at line 163 of file JSystem/JDate.hh.
167 const size_t pos = ( datestr.find(
'Z') != string::npos ? datestr.find(
'Z') :
168 (datestr.find(
'+') != string::npos ? datestr.find(
'+') : datestr.find(
'-')) );
170 if (pos != string::npos) {
174 const string td = datestr.substr(0, pos);
175 const string tz = datestr.substr(pos+1);
177 const char* p0 = strptime(td.c_str(),
"%FT%T", &t);
178 const char*
p1 = ( tz.size() < 3 ? strptime(tz.c_str(),
"%H", &t) :
179 (tz.size() < 5 ? strptime(tz.c_str(),
"%H%M", &t) : strptime(tz.c_str(),
"%H:%M", &t)) );
181 return ( (p0 != NULL &&
string(p0).empty()) && ((p1 != NULL &&
string(p1).empty()) || tz ==
"Z") );
Get ASCII formatted date and time.
- Parameters
-
- Returns
- ASCII formatted date and time
Definition at line 194 of file JSystem/JDate.hh.
200 static const int MAX_SIZE = 256;
201 static char buffer[MAX_SIZE];
206 strftime(buffer, MAX_SIZE,
"%FT%T%z",
tp);
210 strftime(buffer, MAX_SIZE,
"%a %b %d %X %Z %Y",
tp);
219 buffer[MAX_SIZE-1] =
'\0';
221 return string(buffer);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Human readable format (Www Mmm dd hh:mm:ss yyyy)
Exception for accessing a value in a collection that is outside of its range.
const JDateAndTime& JSYSTEM::JDateAndTime::operator() |
( |
| ) |
const |
|
inline |
Set date and time.
- Returns
- date and time
Definition at line 230 of file JSystem/JDate.hh.
void set() const
Set to actual time.
void JSYSTEM::JDateAndTime::set |
( |
| ) |
const |
|
inline |
void JSYSTEM::JDateAndTime::set |
( |
const time_t |
t1 | ) |
const |
|
inline |
double JSYSTEM::JDateAndTime::getElapsedTime |
( |
const JDateAndTime & |
object | ) |
const |
|
inline |
Get elapsed time since given date and time.
- Parameters
-
- Returns
- time [s]
Definition at line 267 of file JSystem/JDate.hh.
269 return difftime(this->
ts,
object.
ts);
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const JDateAndTime & |
object |
|
) |
| |
|
friend |
Write date and time to output.
- Parameters
-
out | output stream |
object | date and time |
- Returns
- output stream
Definition at line 280 of file JSystem/JDate.hh.
282 return out <<
object.toString();
time_t JSYSTEM::JDateAndTime::ts |
|
mutableprivate |
tm* JSYSTEM::JDateAndTime::tp |
|
mutableprivate |
The documentation for this struct was generated from the following file: