Jpp  master_rocky-43-ge265d140c
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 38 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 50 of file JDate.hh.

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

◆ 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 64 of file JDate.hh.

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

◆ JDate() [3/3]

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

Constructor.

Parameters
datedate

Definition at line 78 of file JDate.hh.

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

Member Function Documentation

◆ min()

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

Minimal date.

Definition at line 86 of file JDate.hh.

◆ max()

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

Maximal date.

Definition at line 87 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 96 of file JDate.hh.

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

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 119 of file JDate.hh.

120  {
121  using namespace std;
122  using namespace JPP;
123 
124  object = JDate();
125 
126  while (isspace(in.peek())) { in.ignore(); }
127 
128  const locale loc = in.imbue(locale(in.getloc(), new JWhiteSpacesFacet(in.getloc(), JDate::SEPARATOR)));
129 
130  in >> object.year >> object.month >> object.day;
131 
132  in.imbue(loc);
133 
134  return in;
135  }
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:50
static const char SEPARATOR
Separation character.
Definition: JDate.hh:44

◆ 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 145 of file JDate.hh.

146  {
147  return out << FILL(4,'0') << object.year << JDate::SEPARATOR
148  << FILL(2,'0') << object.month << JDate::SEPARATOR
149  << FILL(2,'0') << object.day << FILL();
150  }
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 44 of file JDate.hh.

◆ year

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

year

Definition at line 153 of file JDate.hh.

◆ month

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

month

Definition at line 154 of file JDate.hh.

◆ day

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

day

Definition at line 155 of file JDate.hh.


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