* to parse strings of the required format (those that include time zones).
*
* See http://www.w3.org/TR/xmlschema-2/#dateTime
+ *
+ * Note that operator== for this class will return true for times that have different
+ * offsets but are the same actual time.
*/
class LocalTime
{
, _offset(offset)
{}
- /** @return A string of the form 2013-01-05T18:06:59+04:00 or 2013-01-05T18:06:59.123+04:00 */
- std::string as_string (bool with_millisecond = false) const;
+ /** @return A string of the form 2013-01-05T18:06:59+04:00, 2013-01-05T18:06:59.123+04:00
+ * 2013-01-05T18:06:59 or 2013-01-05T18:06:59.123
+ */
+ std::string as_string(bool with_millisecond = false, bool with_timezone = true) const;
/** @return The date in the form YYYY-MM-DD */
std::string date () const;
return _second;
}
+ int millisecond() const {
+ return _millisecond;
+ }
+
+ void set_day(int d) {
+ _day = d;
+ }
+
+ void set_month(int m) {
+ _month = m;
+ }
+
void set_year (int y) {
_year = y;
}
+ void set_offset(UTCOffset offset) {
+ _offset = offset;
+ }
+
void add_days (int d);
void add_months (int a);
void add_minutes (int a);
bool operator== (LocalTime const & other) const;
bool operator!= (LocalTime const & other) const;
bool operator< (LocalTime const & other) const;
+ bool operator<=(LocalTime const & other) const;
bool operator>(LocalTime const & other) const;
+ bool operator>=(LocalTime const & other) const;
private:
friend struct ::local_time_basic_test;
void set (struct tm const * tm);
void set (boost::posix_time::ptime);
void set_local_time_zone ();
+ dcp::LocalTime as_utc() const;
/* Local time */
int _year = 0; ///< year