diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-17 22:03:32 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-17 22:03:32 -0500 |
commit | a866f39210534052bc77c975344706c84c39a4a9 (patch) | |
tree | 2347a1cea2c22ab2aedbb1cc8f480d6580ddb631 /src/times.h | |
parent | c28d828d8e24fe637a74674bedc9bc0cbdabca1c (diff) | |
download | fork-ledger-a866f39210534052bc77c975344706c84c39a4a9.tar.gz fork-ledger-a866f39210534052bc77c975344706c84c39a4a9.tar.bz2 fork-ledger-a866f39210534052bc77c975344706c84c39a4a9.zip |
Added a date_traits_t type
Diffstat (limited to 'src/times.h')
-rw-r--r-- | src/times.h | 44 |
1 files changed, 44 insertions, 0 deletions
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<class Archive> + 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<date_interval_t> { public: |