// Zoe AIM Away Message RSS Feed Generator // // Seth King and Douglas Thrift // // $Id$ #ifndef _Stamp_hpp_ #define _Stamp_hpp_ #include "Zoe.hpp" #include template class Period { private: std::time_t seconds; public: Period(std::time_t period) : seconds(period * Seconds) {} operator std::time_t() const { return seconds; } }; typedef Period<60> Minute; typedef Period<3600> Hour; typedef Period<86400> Day; class Stamp { private: std::time_t when; std::tm stamp; public: Stamp(std::time_t when = std::time(NULL)) : when(when) { gmtime_r(&when, &stamp); } Stamp(const ext::String& when); ext::String get822() const; ext::String getW3() const; ext::String get8601() const; ext::String getDate() const; ext::String getTime() const; void setSeconds(int seconds); void setMinutes(int minutes); operator ext::String() const; Stamp operator+(std::time_t seconds) const { return when + seconds; } Stamp operator-(std::time_t seconds) const { return when - seconds; } bool operator<(const Stamp& stamp) const { return when < stamp.when; } bool operator>(const Stamp& stamp) const { return when > stamp.when; } }; inline ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Stamp& stamp) { return pout << ext::String(stamp); } #endif // _Stamp_hpp_