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(int32_t, uint8_t, uint8_t);
28 DateTime(int32_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
29 DateTime(int32_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint32_t);
31 int32_t get_year() const { return year; }
32 uint8_t get_month() const { return month; }
33 uint8_t get_mday() const { return mday; }
34 uint8_t get_hour() const { return hour; }
35 uint8_t get_minute() const { return minute; }
36 uint8_t get_second() const { return second; }
37 uint32_t get_usec() const { return usec; }
39 void add_days(int32_t);
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(int64_t);