Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDate_t.hh
Go to the documentation of this file.
1 #ifndef __JDB_JDATE_T__
2 #define __JDB_JDATE_T__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "Jeep/JDate.hh"
8 #include "Jeep/JTime.hh"
9 
11 
12 
13 /**
14  * \author mdejong
15  */
16 namespace JDATABASE {}
17 namespace JPP { using namespace JDATABASE; }
18 
19 namespace JDATABASE {
20 
22  using JLANG::JTYPELIST;
23 
24  typedef JEEP::JDate<'/'> JDate_t; //!< type defintion of date according database format
25  typedef JEEP::JTime<':'> JTime_t; //!< type defintion of time according database format
26 
27 
28  /**
29  * Date and time.
30  */
31  struct JDateAndTime_t :
32  public JDate_t,
33  public JTime_t,
34  public JMultiComparable<JDateAndTime_t, JTYPELIST<JDate_t, JTime_t>::typelist>
35  {
36  /**
37  * Separation character.
38  */
39  static const char SEPARATOR = '-';
40 
41 
42  /**
43  * Default constructor;
44  */
46  {}
47 
48 
49  /**
50  * Read date and time from input stream.
51  *
52  * \param in input stream
53  * \param object date and time
54  * \return input stream
55  */
56  friend inline std::istream& operator>>(std::istream& in, JDateAndTime_t& object)
57  {
58  in >> static_cast<JDate_t&>(object);
59 
60  if (in.get() == (int) SEPARATOR) {
61  in >> static_cast<JTime_t&>(object);
62  }
63 
64  return in;
65  }
66 
67 
68  /**
69  * Write date and time to output stream.
70  *
71  * \param out output stream
72  * \param object date and time
73  * \return output stream
74  */
75  friend inline std::ostream& operator<<(std::ostream& out, const JDateAndTime_t& object)
76  {
77  out << static_cast<const JDate_t&>(object);
78  out << SEPARATOR;
79  out << static_cast<const JTime_t&>(object);
80 
81  return out;
82  }
83  };
84 
85 
86  /**
87  * Date and time.
88  */
90  public JDateAndTime_t
91  {
92  /**
93  * Default constructor;
94  */
96  {}
97 
98 
99  /**
100  * Read date and time from input stream.
101  *
102  * \param in input stream
103  * \param object date and time
104  * \return input stream
105  */
106  friend inline std::istream& operator>>(std::istream& in, JDateAndTimeUS_t& object)
107  {
108  using namespace std;
109  using namespace JPP;
110 
111  object = JDateAndTimeUS_t();
112 
113  while (isspace(in.peek())) { in.ignore(); }
114 
115  const locale loc = in.imbue(locale(in.getloc(), new JWhiteSpacesFacet(in.getloc(), JDate_t::SEPARATOR)));
116 
117  in >> object.month >> object.day >> object.year;
118 
119  if (in.get() == (int) ' ') {
120 
121  in.imbue(locale(in.getloc(), new JWhiteSpacesFacet(in.getloc(), JTime_t::SEPARATOR)));
122 
123  in >> object.hour >> object.minute >> object.second;
124 
125  if (in.get() == (int) ' ') {
126 
127  string key;
128 
129  in >> key;
130 
131  if (key == "am" || key == "AM") {}
132  if (key == "pm" || key == "PM") { object.hour += 12; }
133  }
134  }
135 
136  in.imbue(loc);
137 
138  return in;
139  }
140  };
141 }
142 
143 #endif
static const char SEPARATOR
Separation character.
Definition: JDate.hh:45
Date and time.
Definition: JDate_t.hh:31
JDateAndTime_t()
Default constructor;.
Definition: JDate_t.hh:45
JDateAndTimeUS_t()
Default constructor;.
Definition: JDate_t.hh:95
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
Auxiliary class for simple date.
Definition: JDate.hh:39
friend std::ostream & operator<<(std::ostream &out, const JDateAndTime_t &object)
Write date and time to output stream.
Definition: JDate_t.hh:75
static const char SEPARATOR
Separation character.
Definition: JDate_t.hh:39
JEEP::JTime<':'> JTime_t
type defintion of time according database format
Definition: JDate_t.hh:25
Date and time.
Definition: JDate_t.hh:89
friend std::istream & operator>>(std::istream &in, JDateAndTimeUS_t &object)
Read date and time from input stream.
Definition: JDate_t.hh:106
static const char SEPARATOR
Separation character.
Definition: Jeep/JTime.hh:45
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
friend std::istream & operator>>(std::istream &in, JDateAndTime_t &object)
Read date and time from input stream.
Definition: JDate_t.hh:56
Template definition of auxiliary base class for composite data structures composed of base classes wi...
Auxiliary class for simple time.
Definition: Jeep/JTime.hh:39
char * loc(char *orig)
JEEP::JDate<'/'> JDate_t
type defintion of date according database format
Definition: JDate_t.hh:24