1 #ifndef __JSYSTEM__JDATEANDTIME__ 
    2 #define __JSYSTEM__JDATEANDTIME__ 
   39     static const size_t     MAX_SIZE = 256;
 
   40     static char      buffer[MAX_SIZE];
 
   44     strftime(buffer, MAX_SIZE, 
"%F", localtime(&ts));
 
   58     static const size_t     MAX_SIZE = 256;
 
   59     static char      buffer[MAX_SIZE];
 
   63     strftime(buffer, MAX_SIZE, 
"%T%z",  localtime(&ts));
 
  124       std::istringstream is(buffer);
 
  182     operator std::string()
 const 
  204       catch(
const std::exception& error) {
 
  219       static const size_t     MAX_SIZE = 256;
 
  220       static char      buffer[MAX_SIZE];
 
  222       const size_t pos = strftime(buffer, MAX_SIZE, (
isUTC() ? 
"%FT%TZ" : 
"%FT%T%z"), this->
get());
 
  224       return string(buffer, pos);
 
  262     void set(
const time_t t1, 
const bool utc = 
false)
 
  276     void set(
const time_t t1, 
const float f1, 
const bool utc = 
false)
 
  314       return difftime(
object.
ts, this->ts) + (
object.fs - this->
fs);
 
  329       const size_t LENGTH = 10;                                     
 
  333       for (
int c; (c = in.peek()) != EOF && isspace((
char) in.peek()); ) {
 
  337       for (
int c; (c = in.get()) != EOF && (c != 
' ' || buffer.length() == LENGTH); ) {
 
  338         buffer.push_back((
char) c);
 
  347       size_t pos = string::npos;
 
  349       if (pos == string::npos) { pos = buffer.find(
'Z', LENGTH); }  
 
  350       if (pos == string::npos) { pos = buffer.find(
'+', LENGTH); }  
 
  351       if (pos == string::npos) { pos = buffer.find(
'-', LENGTH); }  
 
  357       const string td = buffer.substr(0, pos);
 
  358       const char*  pd = NULL;
 
  360       switch (td.length()) {
 
  371         pd = strptime(td.c_str(), 
"%Y-%m-%d %H:%M:%S",  &tx);  sscanf(pd, 
"%f%n", &
object.
fs, &nd);  pd += nd;
 
  375         pd = strptime(td.c_str(), 
"%Y-%m-%dT%H:%M:%S",  &tx);
 
  379         pd = strptime(td.c_str(), 
"%Y%m%dT%H%M%s",      &tx);
 
  383         pd = strptime(td.c_str(), 
"%Y-%m-%d",           &tx);
 
  387       if (pd == NULL || *pd != 
'\0') {
 
  396       if (pos != string::npos && (buffer[pos] == 
'+' || 
 
  397                                   buffer[pos] == 
'-')) {
 
  399         const string tz = buffer.substr(pos + 1);
 
  400         const char*  pz = tz.c_str();
 
  402         switch (tz.length()) {
 
  405           pz = strptime(tz.c_str(), 
"%H",                 &ty);
 
  409           pz = strptime(tz.c_str(), 
"%H%M",               &ty);
 
  413           pz = strptime(tz.c_str(), 
"%H:%M",              &ty);
 
  417         if (pz == NULL || *pz != 
'\0') {
 
  424       time_t t1 = mktime(&tx);
 
  426       t1  -=  (ty.tm_hour * 60 + ty.tm_min) * 60;                   
 
  427       t1  +=  mktime(localtime(&t1)) - mktime(gmtime(&t1));         
 
  429       object.set(t1, buffer[pos] == 
'Z');
 
  444       return out << 
object.toString();
 
  455       return (this->
tp  = (
utc ? gmtime(&
ts) : localtime(&
ts)));
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
Exception for parsing value.
 
const JPolynome f1(1.0, 2.0, 3.0)
Function.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary classes and methods for operating system calls.
 
const char * getTime()
Get current local time conform ISO-8601 standard.
 
static JDateAndTime getDateAndTime
Function object to get current date and time.
 
const char * getDate()
Get current local date conform ISO-8601 standard.
 
Template definition of auxiliary base class for comparison of data structures.
 
Auxiliary class for date and time.
 
JDateAndTime(const bool utc=false)
Constructor.
 
bool isUTC() const
Check if UTC time.
 
double getElapsedTime(const JDateAndTime &object) const
Get elapsed time to given date and time.
 
friend std::ostream & operator<<(std::ostream &out, const JDateAndTime &object)
Write date and time to output stream.
 
JDateAndTime(const std::string &buffer)
Constructor.
 
std::string toString() const
Get ASCII formatted date and time.
 
JDateAndTime(const time_t t1, const float f1, const bool utc=false)
Constructor.
 
int getMinutes() const
minutes after the hour [0-59]
 
int getYear() const
year a.d.
 
time_t getTime() const
time
 
int getHour() const
hours after midnight [0-23]
 
int getDST() const
daylight saving time
 
void set(const bool utc=false)
Set to current local time.
 
bool less(const JDateAndTime &object) const
Less than method.
 
int getDay() const
day of the month [1-31]
 
const tm * operator->() const
Smart pointer.
 
friend std::istream & operator>>(std::istream &in, JDateAndTime &object)
Read date and time from input stream.
 
float getFS() const
fraction of second
 
const JDateAndTime & operator()()
Set date and time.
 
tm * get() const
Get representation.
 
int getMonth() const
month of the year [1-12]
 
JDateAndTime(const time_t t1, const bool utc=false)
Constructor.
 
static bool isISO8601(const std::string &buffer)
Function to check ISO-8601 conformity.
 
int getSeconds() const
seconds after the minute [0-59]
 
void set(const time_t t1, const bool utc=false)
Set to given time.
 
void sub(const time_t t1)
Subtract given time.
 
void add(const time_t t1)
Add given time.
 
float fs
fraction of second
 
void set(const time_t t1, const float f1, const bool utc=false)
Set to given time.