ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Stamp.hpp
Revision: 60
Committed: 2004-09-15T19:43:29-07:00 (20 years, 9 months ago) by douglas
File size: 1299 byte(s)
Log Message:
Switched to ios::PrintWriter from std::istream, using ios::String instead of
lexical_cast for UUIDs, worky, worky!

File Contents

# Content
1 // Zoe AIM Away Message RSS Feed Generator
2 //
3 // Seth King and Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _Stamp_hpp_
8 #define _Stamp_hpp_
9
10 #include "Zoe.hpp"
11
12 #include <ctime>
13
14 template<int Seconds>
15 class Period
16 {
17 private:
18 std::time_t seconds;
19 public:
20 Period(std::time_t period) : seconds(period * Seconds) {}
21 operator std::time_t() const { return seconds; }
22 };
23
24 typedef Period<60> Minute;
25 typedef Period<3600> Hour;
26 typedef Period<86400> Day;
27
28 class Stamp
29 {
30 private:
31 std::time_t when;
32 std::tm stamp;
33 public:
34 Stamp(std::time_t when = std::time(NULL)) : when(when) { gmtime_r(&when,
35 &stamp); }
36 Stamp(const ext::String& when);
37 ext::String get822() const;
38 ext::String getW3() const;
39 ext::String get8601() const;
40 ext::String getDate() const;
41 ext::String getTime() const;
42 void setSeconds(int seconds);
43 void setMinutes(int minutes);
44 operator ext::String() const;
45 Stamp operator+(std::time_t seconds) const { return when + seconds; }
46 Stamp operator-(std::time_t seconds) const { return when - seconds; }
47 bool operator<(const Stamp& stamp) const { return when < stamp.when; }
48 bool operator>(const Stamp& stamp) const { return when > stamp.when; }
49 };
50
51 inline ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Stamp& stamp)
52 {
53 return pout << ext::String(stamp);
54 }
55
56 #endif // _Stamp_hpp_

Properties

Name Value
svn:eol-style native
svn:keywords Id