1 #ifndef MSP_TIME_DATETIME_H_
2 #define MSP_TIME_DATETIME_H_
15 Provides handling of arbitary dates and times. Can represent a moment of time
16 in the range of about ±2.1×10⁹ years. It can also be formatted into a string
17 for presentation to the user.
19 Due to the complex internal representation, arithmetic operations on a DateTime
20 are relatively slow. For purposes of internal scheduling in a program, a
21 TimeStamp is a better choice.
36 DateTime(const TimeStamp &);
37 DateTime(const TimeStamp &, const TimeZone &);
38 DateTime(int, unsigned char, unsigned char);
39 DateTime(int, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char);
40 DateTime(int, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned);
42 void init(const TimeStamp &);
43 void init(int, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned);
46 int get_year() const { return year; }
47 unsigned char get_month() const { return month; }
48 unsigned char get_mday() const { return mday; }
49 unsigned char get_hour() const { return hour; }
50 unsigned char get_minute() const { return minute; }
51 unsigned char get_second() const { return second; }
52 unsigned get_usec() const { return usec; }
55 void set_timezone(const TimeZone &);
56 void convert_timezone(const TimeZone &);
58 DateTime operator+(const TimeDelta &) const;
59 DateTime &operator+=(const TimeDelta &);
60 DateTime operator-(const TimeDelta &) const;
61 DateTime &operator-=(const TimeDelta &);
63 bool operator==(const DateTime &d) const { return cmp(d)==0; }
64 bool operator!=(const DateTime &d) const { return cmp(d)!=0; }
65 bool operator<(const DateTime &d) const { return cmp(d)<0; }
66 bool operator<=(const DateTime &d) const { return cmp(d)<=0; }
67 bool operator>(const DateTime &d) const { return cmp(d)>0; }
68 bool operator>=(const DateTime &d) const { return cmp(d)>=0; }
70 int cmp(const DateTime &) const;
71 TimeStamp get_timestamp() const;
72 std::string format(const std::string &) const;
73 std::string format_rfc3339() const;
76 void add_raw(RawTime);
80 inline void operator<<(LexicalConverter &c, const DateTime &d)
81 { c.result(d.format_rfc3339()); }