From a866f39210534052bc77c975344706c84c39a4a9 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 17 Nov 2009 22:03:32 -0500 Subject: Added a date_traits_t type --- src/times.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/times.h') diff --git a/src/times.h b/src/times.h index 84970cd2..676ec450 100644 --- a/src/times.h +++ b/src/times.h @@ -138,6 +138,50 @@ inline void to_xml(std::ostream& out, const date_t& when, } } +struct date_traits_t +{ + bool has_year; + bool has_month; + bool has_day; + + date_traits_t(bool _has_year = false, + bool _has_month = false, + bool _has_day = false) + : has_year(_has_year), has_month(_has_month), has_day(_has_day) {} + + date_traits_t(const date_traits_t& traits) + : has_year(traits.has_year), + has_month(traits.has_month), + has_day(traits.has_day) {} + + date_traits_t& operator=(const date_traits_t& traits) { + has_year = traits.has_year; + has_month = traits.has_month; + has_day = traits.has_day; + return *this; + } + + bool operator==(const date_traits_t& traits) const { + return (has_year == traits.has_year && + has_month == traits.has_month && + has_day == traits.has_day); + } + +#if defined(HAVE_BOOST_SERIALIZATION) +private: + /** Serialization. */ + + friend class boost::serialization::access; + + template + void serialize(Archive& ar, const unsigned int /* version */) { + ar & has_year; + ar & has_month; + ar & has_day; + } +#endif // HAVE_BOOST_SERIALIZATION +}; + class date_interval_t : public equality_comparable { public: -- cgit v1.2.3