neic-glass3  1.4.6
date.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef DATE_H
8 #define DATE_H
9 
10 #include <ctime>
11 #include <string>
12 
13 namespace glass3 {
14 namespace util {
15 
26 class Date {
27  public:
33  Date();
34 
43  explicit Date(double time);
44 
58  Date(unsigned int year, unsigned int month, unsigned int day,
59  unsigned int hour, unsigned int minutes, double seconds);
60 
69  explicit Date(std::string time);
70 
76  ~Date();
77 
83  void clear();
84 
91  static double now();
92 
102  bool initialize(double time);
103 
118  bool initialize(unsigned int year, unsigned int month, unsigned int day,
119  unsigned int hour, unsigned int minutes, double seconds);
120 
130  bool initialize(std::string time);
131 
138  unsigned int year();
139 
146  unsigned int month();
147 
154  unsigned int day();
155 
162  unsigned int hour();
163 
170  unsigned int minute();
171 
178  double seconds();
179 
186  double time();
187 
195  std::string date18();
196 
204  std::string date20();
205 
214  std::string ISO8601();
215 
224  std::string dateTime();
225 
233  double decodeDateTime(std::string datetime);
234 
242  double decodeISO8601Time(std::string iso8601);
243 
252  static std::string encodeDateTime(double t);
253 
262  static std::string encodeISO8601Time(double t);
263 
280  static std::string convertEpochTimeToISO8601(double epochTime);
281 
300  static std::string convertEpochTimeToISO8601(std::time_t epochTime,
301  double decimalSeconds = 0);
302 
317  static std::string convertDateTimeToISO8601(const std::string &timeString);
318 
333  static double convertDateTimeToEpochTime(const std::string &timeString);
334 
352  static double convertISO8601ToEpochTime(const std::string &timeString);
353 
354  protected:
358  unsigned int m_nYear;
359 
363  unsigned int m_nMonth;
364 
368  unsigned int m_nDay;
369 
373  unsigned int m_nHour;
374 
378  unsigned int m_nMinute;
379 
383  double m_dSeconds;
384 
388  double m_dTime;
389 };
390 } // namespace util
391 } // namespace glass3
392 #endif // DATE_H
time translation class
Definition: date.h:26
static double convertISO8601ToEpochTime(const std::string &timeString)
Convert time from ISO8601 time to epoch time.
Definition: date.cpp:507
unsigned int year()
Get the gregorian year.
Definition: date.cpp:257
static std::string encodeDateTime(double t)
Calculate (encode) the date time date string.
Definition: date.cpp:438
unsigned int hour()
Get the gregorian hour.
Definition: date.cpp:272
static double convertDateTimeToEpochTime(const std::string &timeString)
Convert time from date time to epoch time.
Definition: date.cpp:637
static std::string encodeISO8601Time(double t)
Calculate (encode) the ISO8610 date string.
Definition: date.cpp:444
double decodeDateTime(std::string datetime)
Decode the datetime format date string into Gregorian seconds.
Definition: date.cpp:358
std::string date20()
Calculate the 18 character date string.
Definition: date.cpp:315
static std::string convertEpochTimeToISO8601(double epochTime)
Convert time from epoch time to ISO8601.
Definition: date.cpp:450
unsigned int m_nYear
An unsigned integer variable containing the gregorian year.
Definition: date.h:358
std::string ISO8601()
Calculate the ISO8601 date string.
Definition: date.cpp:330
Date()
CDate default constructor.
Definition: date.cpp:38
unsigned int m_nMonth
An unsigned integer variable containing the gregorian month.
Definition: date.h:363
double time()
Get the Gregorian seconds.
Definition: date.cpp:287
The neic-glass3 project namespace containing all the classes and functions that make up neic-glass3...
double m_dSeconds
A double variable containing the gregorian seconds.
Definition: date.h:383
double m_dTime
A double variable containing the Gregorian seconds.
Definition: date.h:388
unsigned int minute()
Get the gregorian minute.
Definition: date.cpp:277
std::string date18()
Calculate the 20 character date string.
Definition: date.cpp:292
std::string dateTime()
Calculate the DateTime date string.
Definition: date.cpp:344
unsigned int m_nMinute
An unsigned integer variable containing the gregorian minute.
Definition: date.h:378
unsigned int day()
Get the gregorian day.
Definition: date.cpp:267
unsigned int m_nDay
An unsigned integer variable containing the gregorian day.
Definition: date.h:368
static double now()
CDate current time function.
Definition: date.cpp:80
static std::string convertDateTimeToISO8601(const std::string &timeString)
Convert time from date time format to ISO8601 format.
Definition: date.cpp:500
unsigned int month()
Get the gregorian month.
Definition: date.cpp:262
double decodeISO8601Time(std::string iso8601)
Decode the ISO8601 date string into Gregorian seconds.
Definition: date.cpp:402
void clear()
CDate clear function.
Definition: date.cpp:69
~Date()
CDate destructor.
Definition: date.cpp:65
double seconds()
Get the gregorian seconds.
Definition: date.cpp:282
unsigned int m_nHour
An unsigned integer variable containing the gregorian hour.
Definition: date.h:373
bool initialize(double time)
CDate initialize function.
Definition: date.cpp:104