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 |
class Stamp |
15 |
{ |
16 |
private: |
17 |
std::tm stamp; |
18 |
public: |
19 |
Stamp(std::time_t now = std::time(NULL)) { gmtime_r(&now, &stamp); } |
20 |
Stamp(const ext::String& when); |
21 |
operator ext::String() const; |
22 |
Stamp operator+(int days) const; |
23 |
Stamp operator-(int days) const { return *this + -days; } |
24 |
Stamp& operator++() { *this += 1; return *this; } |
25 |
Stamp operator++(int) { Stamp stamp(*this); *this += 1; return stamp; } |
26 |
Stamp& operator+=(int days) { *this = *this + days; return *this; } |
27 |
Stamp& operator--() { *this -= 1; return *this; } |
28 |
Stamp operator--(int) { Stamp stamp(*this); *this -= 1; return stamp; } |
29 |
Stamp& operator-=(int days) { *this = *this - days; return *this; } |
30 |
}; |
31 |
|
32 |
inline ext::String operator+(const Stamp& stamp, const ext::String& string) |
33 |
{ |
34 |
return ext::String(stamp) + string; |
35 |
} |
36 |
|
37 |
inline ext::String operator+(const ext::String& string, const Stamp& stamp) |
38 |
{ |
39 |
return string + ext::String(stamp); |
40 |
} |
41 |
|
42 |
#endif // _Stamp_hpp_ |