11 #ifdef HAVE_SYS_TYPES_H
12 #include <sys/types.h>
87 year = l->tm_year + 1900;
88 month = l->tm_mon + 1;
94 assert(ts.
year() == year);
95 assert(ts.
month() == month);
96 assert(ts.
day() == day);
97 assert(ts.
hour() == hour);
98 assert(ts.
minute() == minute);
99 assert(ts.
second() == second);
107 thrown =
false;
try { t.
assign(
""); }
catch(...) { thrown =
true; }
110 thrown =
false;
try { t.
assign(
"a"); }
catch(...) { thrown =
true; }
113 thrown =
false;
try { t.
assign(
"2"); }
catch(...) { thrown =
true; }
116 thrown =
false;
try { t.
assign(
"20"); }
catch(...) { thrown =
true; }
119 thrown =
false;
try { t.
assign(
"200"); }
catch(...) { thrown =
true; }
122 thrown =
false;
try { t.
assign(
"2003"); }
catch(...) { thrown =
true; }
124 assert(t.
year() == 2003);
125 assert(t.
month() == 1);
126 assert(t.
day() == 1);
127 assert(t.
hour() == 0);
132 thrown =
false;
try { t.
assign(
"2a03"); }
catch(...) { thrown =
true; }
135 thrown =
false;
try { t.
assign(
"2003-"); }
catch(...) { thrown =
true; }
138 thrown =
false;
try { t.
assign(
"2003-1"); }
catch(...) { thrown =
true; }
141 thrown =
false;
try { t.
assign(
"2003-10"); }
catch(...) { thrown =
true; }
143 assert(t.
year() == 2003);
144 assert(t.
month() == 10);
145 assert(t.
day() == 1);
146 assert(t.
hour() == 0);
151 thrown =
false;
try { t.
assign(
"2003-1b"); }
catch(...) { thrown =
true; }
154 thrown =
false;
try { t.
assign(
"2003-19"); }
catch(...) { thrown =
true; }
157 thrown =
false;
try { t.
assign(
"2003-10-"); }
catch(...) { thrown =
true; }
160 thrown =
false;
try { t.
assign(
"2003-10-1"); }
catch(...) { thrown =
true; }
163 thrown =
false;
try { t.
assign(
"2003-10-19"); }
catch(...) { thrown =
true; }
165 assert(t.
year() == 2003);
166 assert(t.
month() == 10);
167 assert(t.
day() == 19);
168 assert(t.
hour() == 0);
173 thrown =
false;
try { t.
assign(
"2003-10-19."); }
catch(...) { thrown =
true; }
176 thrown =
false;
try { t.
assign(
"2003-10-19.2"); }
catch(...) { thrown =
true; }
179 thrown =
false;
try { t.
assign(
"2003-10-19.24"); }
catch(...) { thrown =
true; }
182 thrown =
false;
try { t.
assign(
"2003-10-19.23"); }
catch(...) { thrown =
true; }
184 assert(t.
year() == 2003);
185 assert(t.
month() == 10);
186 assert(t.
day() == 19);
187 assert(t.
hour() == 23);
192 thrown =
false;
try { t.
assign(
"2003-10-19.230"); }
catch(...) { thrown =
true; }
195 thrown =
false;
try { t.
assign(
"2003-10-19.2307"); }
catch(...) { thrown =
true; }
197 assert(t.
year() == 2003);
198 assert(t.
month() == 10);
199 assert(t.
day() == 19);
200 assert(t.
hour() == 23);
205 thrown =
false;
try { t.
assign(
"2003-10-19.23070"); }
catch(...) { thrown =
true; }
208 thrown =
false;
try { t.
assign(
"2003-10-19.230708"); }
catch(...) { thrown =
true; }
210 assert(t.
year() == 2003);
211 assert(t.
month() == 10);
212 assert(t.
day() == 19);
213 assert(t.
hour() == 23);
218 thrown =
false;
try { t.
assign(
"2003-10-19.2307089"); }
catch(...) { thrown =
true; }
222 int main(
int argc,
char const * argv[])
int year(void) const
Return the timestamp year.
int day(void) const
Return the timestamp day.
An extended string class.
int month(void) const
Return the timestamp month.
int main(int argc, char const *argv[])
char left_fillchar(const char a_char)
Set the fill character used to padd the left side of a formatted string.
void assign(const timestamp &a_t)
Set the timestamp to the value of another timestamp.
value_type fmt_str(void)
Generate a formatted string.
int second(void) const
Return the timestamp second.
void resolution(resolution_type a_r)
Set the timestamp resolution.
void set(void)
Set the timestamp to the current time and date.
size_type width(const size_type a_l)
Set the width of a formatted string.
int hour(void) const
Return the timestamp hour.
alignment align(const alignment a_alignment)
Set the alignment used for formatted strings.
const std::string str(void) const
Generate a string.
int minute(void) const
Return the timestamp minute.