2 #ifndef MSP_TIME_DATETIME_H_
3 #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.
26 DateTime(const TimeStamp &);
27 DateTime(int, unsigned char, unsigned char);
28 DateTime(int, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char);
29 DateTime(int, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned);
31 int get_year() const { return year; }
32 unsigned char get_month() const { return month; }
33 unsigned char get_mday() const { return mday; }
34 unsigned char get_hour() const { return hour; }
35 unsigned char get_minute() const { return minute; }
36 unsigned char get_second() const { return second; }
37 unsigned get_usec() const { return usec; }
41 DateTime operator+(const TimeDelta &) const;
42 DateTime &operator+=(const TimeDelta &);
44 bool operator==(const DateTime &d) const { return cmp(d)==0; }
45 bool operator!=(const DateTime &d) const { return cmp(d)!=0; }
46 bool operator<(const DateTime &d) const { return cmp(d)<0; }
47 bool operator<=(const DateTime &d) const { return cmp(d)<=0; }
48 bool operator>(const DateTime &d) const { return cmp(d)>0; }
49 bool operator>=(const DateTime &d) const { return cmp(d)>=0; }
51 int cmp(const DateTime &) const;
52 TimeStamp get_timestamp() const;
53 std::string format(const std::string &) const;
63 void add_raw(RawTime);
65 void validate() const;