1 |
douglas |
21 |
// Zoe AIM Away Message RSS Feed Generator |
2 |
|
|
// |
3 |
|
|
// Seth King and Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include "Stamp.hpp" |
8 |
|
|
|
9 |
douglas |
27 |
Stamp::Stamp(const ext::String& when) |
10 |
douglas |
21 |
{ |
11 |
douglas |
27 |
strptime(when.NullTerminate(), "%F %T", &stamp); |
12 |
douglas |
31 |
|
13 |
|
|
this->when = timegm(&stamp); |
14 |
douglas |
21 |
} |
15 |
|
|
|
16 |
douglas |
36 |
ext::String Stamp::get822() const |
17 |
douglas |
21 |
{ |
18 |
|
|
char when[30]; |
19 |
|
|
|
20 |
douglas |
24 |
std::strftime(when, 30, "%a, %d %b %Y %T GMT", &stamp); |
21 |
douglas |
21 |
|
22 |
|
|
return when; |
23 |
|
|
} |
24 |
douglas |
36 |
|
25 |
|
|
ext::String Stamp::getW3() const |
26 |
|
|
{ |
27 |
|
|
char when[21]; |
28 |
|
|
|
29 |
|
|
std::strftime(when, 21, "%FT%TZ", &stamp); |
30 |
|
|
|
31 |
|
|
return when; |
32 |
|
|
} |
33 |
douglas |
37 |
|
34 |
douglas |
39 |
ext::String Stamp::getDate() const |
35 |
|
|
{ |
36 |
|
|
char date[11]; |
37 |
|
|
|
38 |
|
|
std::strftime(date, 11, "%m/%d/%Y", &stamp); |
39 |
|
|
|
40 |
|
|
return date; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
ext::String Stamp::getTime() const |
44 |
|
|
{ |
45 |
|
|
char time[12]; |
46 |
|
|
|
47 |
|
|
std::strftime(time, 12, "%I:%M:%S %p", &stamp); |
48 |
|
|
|
49 |
|
|
return time; |
50 |
|
|
} |
51 |
|
|
|
52 |
douglas |
37 |
void Stamp::setSeconds(int seconds) |
53 |
|
|
{ |
54 |
|
|
stamp.tm_sec = seconds; |
55 |
|
|
when = timegm(&stamp); |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
void Stamp::setMinutes(int minutes) |
59 |
|
|
{ |
60 |
|
|
stamp.tm_min = minutes; |
61 |
|
|
when = timegm(&stamp); |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
Stamp::operator ext::String() const |
65 |
|
|
{ |
66 |
douglas |
38 |
char when[24]; |
67 |
douglas |
37 |
|
68 |
douglas |
38 |
std::strftime(when, 24, "%F %T GMT", &stamp); |
69 |
douglas |
37 |
|
70 |
|
|
return when; |
71 |
|
|
} |