1 #ifndef __JSYSTEM__JDATE__ 
    2 #define __JSYSTEM__JDATE__ 
   16 namespace JPP { 
using namespace JSYSTEM; }
 
   38     static const int        MAX_SIZE = 256;
 
   39     static char      buffer[MAX_SIZE];
 
   46       strftime(buffer, MAX_SIZE, 
"%x", localtime(&ts));
 
   50       strftime(buffer, MAX_SIZE, 
"%F", localtime(&ts));
 
   70     static const int        MAX_SIZE = 256;
 
   71     static char      buffer[MAX_SIZE];
 
   78       strftime(buffer, MAX_SIZE, 
"%X %Z", localtime(&ts));
 
   82       strftime(buffer, MAX_SIZE, 
"%T%z", localtime(&ts));
 
  151     operator std::string()
 const 
  163     inline static bool isISO8601(
const std::string& datestr)
 
  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") );
 
  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);
 
  254     void set(
const time_t t1)
 const 
  269       return difftime(this->
ts, 
object.
ts);
 
  282       return out << 
object.toString();
 
void set() const 
Set to actual time. 
 
const tm * operator->() const 
Smart pointer. 
 
friend std::ostream & operator<<(std::ostream &out, const JDateAndTime &object)
Write date and time to output. 
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message. 
 
JDateAndTimeFormat
Date and time formats. 
 
int getSeconds() const 
seconds after the minute [0-59] 
 
double getTime(const Hit &hit)
Get true time of hit. 
 
std::string toString(const JDateAndTimeFormat option=ISO8601) const 
Get ASCII formatted date and time. 
 
const JDateAndTime & operator()() const 
Set date and time. 
 
JDateAndTime()
Default constructor. 
 
static JDateAndTime getDateAndTime
Function object to get ASCII formatted date and time. 
 
Human readable format (Www Mmm dd hh:mm:ss yyyy) 
 
int getMonth() const 
month of the year [1-12] 
 
static bool isISO8601(const std::string &datestr)
Function to check ISO-8601 conformity of string-formatted date and time. 
 
const char * getDate(const JDateAndTimeFormat option=ISO8601)
Get ASCII formatted date. 
 
int getDay() const 
day of the month [1-31] 
 
double getElapsedTime(const JDateAndTime &object) const 
Get elapsed time since given date and time. 
 
void set(const time_t t1) const 
Set to given time. 
 
Auxililary class to get date and time. 
 
int getHour() const 
hours after midnight [0-23] 
 
int getMinutes() const 
minutes after the hour [0-59] 
 
Exception for accessing a value in a collection that is outside of its range. 
 
int getYear() const 
year a.d. 
 
tm * operator->()
Smart pointer. 
 
JDateAndTime(const time_t t1)
Constructor.