rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tstamp.h
Go to the documentation of this file.
1 #ifndef __tstamp_h__
2 #define __tstamp_h__
3 
4 #ifdef HAVE_SYS_TIME_H
5 #include <sys/types.h>
6 #endif
7 #include <time.h>
8 
9 #include "asserts.h"
10 #include "types.h"
11 
12 /** Timestamp object */
13 class timestamp
14 {
15 public:
23  };
24 
25  timestamp();
26  timestamp(const timestamp& a_t);
27  timestamp(
28  const int a_year,
29  const int a_month,
30  const int a_day,
31  const int a_hour,
32  const int a_minute,
33  const int a_second
34  );
35  timestamp(const std::string& a_s);
36 
37  void set(void);
38  void assign(const timestamp& a_t);
39  void assign(
40  const int a_year,
41  const int a_month,
42  const int a_day,
43  const int a_hour,
44  const int a_minute,
45  const int a_second
46  );
47  void assign(const std::string& a_s);
48  void clear(void);
49  void resolution(resolution_type a_r);
50  resolution_type resolution(void) const;
51 
52  const std::string str(void) const;
53  const std::string str(const resolution_type a_resolution) const;
54  int second(void) const;
55  int minute(void) const;
56  int hour(void) const;
57  int day(void) const;
58  int month(void) const;
59  int year(void) const;
60 
61  timestamp& operator = (const timestamp& a_t);
62  timestamp& operator = (const std::string& a_s);
63  bool operator < (const timestamp& a_t) const;
64  bool operator > (const timestamp& a_t) const;
65  bool operator == (const timestamp& a_t) const;
66 
67 private:
68  int m_year;
69  int m_month;
70  int m_day;
71  int m_hour;
72  int m_minute;
73  int m_second;
75 
76  const std::string make_str_(const int a_resolution) const;
77 };
78 
79 bool is_timestamp(const std::string& a_s);
80 
81 /** A null timestamp */
82 const timestamp null_timestamp(0,1,1,0,0,0);
83 
84 /** The minimum timestamp value */
86 
87 /** The maximum timestamp value */
88 const timestamp max_timestamp(9999,12,31,23,59,59);
89 
90 #endif
Timestamp object.
Definition: tstamp.h:13
int m_day
Definition: tstamp.h:70
void clear(void)
Clear the timestamp.
Definition: tstamp.cc:290
resolution_type resolution(void) const
Return the timestamp resolution.
Definition: tstamp.cc:444
timestamp()
C'tor.
Definition: tstamp.cc:23
int year(void) const
Return the timestamp year.
Definition: tstamp.cc:438
int day(void) const
Return the timestamp day.
Definition: tstamp.cc:426
Basic types definitions and templates.
const timestamp null_timestamp(0, 1, 1, 0, 0, 0)
A null timestamp.
bool is_timestamp(const std::string &a_s)
Return true if the string is a valid timestamp.
Definition: tstamp.cc:502
int m_month
Definition: tstamp.h:69
resolution_type m_resolution
Definition: tstamp.h:74
int month(void) const
Return the timestamp month.
Definition: tstamp.cc:432
bool operator<(const timestamp &a_t) const
Comparison.
Definition: tstamp.cc:466
int m_second
Definition: tstamp.h:73
bool operator>(const timestamp &a_t) const
Comparison.
Definition: tstamp.cc:478
void assign(const timestamp &a_t)
Set the timestamp to the value of another timestamp.
Definition: tstamp.cc:79
const timestamp max_timestamp(9999, 12, 31, 23, 59, 59)
The maximum timestamp value.
int second(void) const
Return the timestamp second.
Definition: tstamp.cc:408
int m_minute
Definition: tstamp.h:72
int m_hour
Definition: tstamp.h:71
void set(void)
Set the timestamp to the current time and date.
Definition: tstamp.cc:58
timestamp & operator=(const timestamp &a_t)
Assignment.
Definition: tstamp.cc:450
const std::string make_str_(const int a_resolution) const
Generate a string.
Definition: tstamp.cc:308
int hour(void) const
Return the timestamp hour.
Definition: tstamp.cc:420
resolution_type
Definition: tstamp.h:16
bool operator==(const timestamp &a_t) const
Comparison.
Definition: tstamp.cc:490
const std::string str(void) const
Generate a string.
Definition: tstamp.cc:387
const timestamp min_timestamp(null_timestamp)
The minimum timestamp value.
int m_year
Definition: tstamp.h:68
int minute(void) const
Return the timestamp minute.
Definition: tstamp.cc:414