Jpp  19.1.0-rc.1
the software that should make you happy
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
JEEP::JDate< JSeparator_t > Struct Template Reference

Auxiliary class for simple date. More...

#include <JDate.hh>

Inheritance diagram for JEEP::JDate< JSeparator_t >:
JLANG::JComparable< JFirst_t, JSecond_t > JDATABASE::JDateAndTime_t JDATABASE::JDatim_t JDATABASE::JDateAndTimeUS_t

Public Member Functions

 JDate ()
 Default constructor. More...
 
 JDate (const int year, const int month, const int day)
 Constructor. More...
 
 JDate (const std::string &date)
 Constructor. More...
 
bool less (const JDate &date) const
 Less-than method. More...
 

Static Public Member Functions

static JDate min ()
 Minimal date. More...
 
static JDate max ()
 Maximal date. More...
 

Public Attributes

int year
 year More...
 
int month
 month More...
 
int day
 day More...
 

Static Public Attributes

static const char SEPARATOR = JSeparator_t
 Separation character. More...
 

Friends

std::istream & operator>> (std::istream &in, JDate &object)
 Read date from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JDate &object)
 Write date to output stream. More...
 

Detailed Description

template<char JSeparator_t>
struct JEEP::JDate< JSeparator_t >

Auxiliary class for simple date.

The corresponding ASCII format is yyyy<separator>mm<separator>dd,
where yyyy corresponds to the year, mm to the month and dd to the day.
The separator is defined by the template parameter.

Definition at line 39 of file JDate.hh.

Constructor & Destructor Documentation

◆ JDate() [1/3]

template<char JSeparator_t>
JEEP::JDate< JSeparator_t >::JDate ( )
inline

Default constructor.

Definition at line 51 of file JDate.hh.

51  :
52  year (0),
53  month(0),
54  day (0)
55  {}
int year
year
Definition: JDate.hh:154
int month
month
Definition: JDate.hh:155
int day
day
Definition: JDate.hh:156

◆ JDate() [2/3]

template<char JSeparator_t>
JEEP::JDate< JSeparator_t >::JDate ( const int  year,
const int  month,
const int  day 
)
inline

Constructor.

Parameters
yearyear
monthmonth
dayday

Definition at line 65 of file JDate.hh.

67  :
68  year (year),
69  month(month),
70  day (day)
71  {}

◆ JDate() [3/3]

template<char JSeparator_t>
JEEP::JDate< JSeparator_t >::JDate ( const std::string &  date)
inline

Constructor.

Parameters
datedate

Definition at line 79 of file JDate.hh.

80  {
81  std::istringstream in(date);
82 
83  in >> *this;
84  }

Member Function Documentation

◆ min()

template<char JSeparator_t>
static JDate JEEP::JDate< JSeparator_t >::min ( )
inlinestatic

Minimal date.

Definition at line 87 of file JDate.hh.

◆ max()

template<char JSeparator_t>
static JDate JEEP::JDate< JSeparator_t >::max ( )
inlinestatic

Maximal date.

Definition at line 88 of file JDate.hh.

◆ less()

template<char JSeparator_t>
bool JEEP::JDate< JSeparator_t >::less ( const JDate< JSeparator_t > &  date) const
inline

Less-than method.

Parameters
datedate
Returns
true if this date earlier than given date; else false

Definition at line 97 of file JDate.hh.

98  {
99  if (this->year == date.year) {
100 
101  if (this->month == date.month)
102  return this->day < date.day;
103  else
104  return this->month < date.month;
105 
106  } else {
107 
108  return this->year < date.year;
109  }
110  }

Friends And Related Function Documentation

◆ operator>>

template<char JSeparator_t>
std::istream& operator>> ( std::istream &  in,
JDate< JSeparator_t > &  object 
)
friend

Read date from input stream.

Parameters
ininput stream
objectdate
Returns
input stream

Definition at line 120 of file JDate.hh.

121  {
122  using namespace std;
123  using namespace JPP;
124 
125  object = JDate();
126 
127  while (isspace(in.peek())) { in.ignore(); }
128 
129  const locale loc = in.imbue(locale(in.getloc(), new JWhiteSpacesFacet(in.getloc(), JDate::SEPARATOR)));
130 
131  in >> object.year >> object.month >> object.day;
132 
133  in.imbue(loc);
134 
135  return in;
136  }
Auxiliary class to specify white space character(s) in currect locale.
char * loc(char *orig)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
JDate()
Default constructor.
Definition: JDate.hh:51
static const char SEPARATOR
Separation character.
Definition: JDate.hh:45

◆ operator<<

template<char JSeparator_t>
std::ostream& operator<< ( std::ostream &  out,
const JDate< JSeparator_t > &  object 
)
friend

Write date to output stream.

Parameters
outoutput stream
objectdate
Returns
output stream

Definition at line 146 of file JDate.hh.

147  {
148  return out << FILL(4,'0') << object.year << JDate::SEPARATOR
149  << FILL(2,'0') << object.month << JDate::SEPARATOR
150  << FILL(2,'0') << object.day << FILL();
151  }
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:330

Member Data Documentation

◆ SEPARATOR

template<char JSeparator_t>
const char JEEP::JDate< JSeparator_t >::SEPARATOR = JSeparator_t
static

Separation character.

Definition at line 45 of file JDate.hh.

◆ year

template<char JSeparator_t>
int JEEP::JDate< JSeparator_t >::year

year

Definition at line 154 of file JDate.hh.

◆ month

template<char JSeparator_t>
int JEEP::JDate< JSeparator_t >::month

month

Definition at line 155 of file JDate.hh.

◆ day

template<char JSeparator_t>
int JEEP::JDate< JSeparator_t >::day

day

Definition at line 156 of file JDate.hh.


The documentation for this struct was generated from the following file: