39HTTPDate(
const string &format) {
43 memset(&t, 0,
sizeof(t));
45 bool got_weekday =
false;
46 bool got_month =
false;
48 bool got_year =
false;
49 bool got_hour =
false;
50 bool got_minute =
false;
51 bool got_second =
false;
58 ExpectNext expect_next = EN_none;
61 string token = get_token(format, pos);
62 while (!token.empty()) {
63 ExpectNext expected = expect_next;
64 expect_next = EN_none;
66 if (isdigit(token[0])) {
68 int value = atoi(token.c_str());
69 if (token[token.length() - 1] ==
':') {
75 }
else if (!got_minute) {
78 expect_next = EN_second;
84 }
else if (token[token.length() - 1] ==
'/') {
90 }
else if (!got_day) {
93 expect_next = EN_year;
100 if (expected == EN_second) {
105 }
else if (expected == EN_year) {
110 }
else if (!got_day) {
115 }
else if (!got_year) {
120 }
else if (!got_hour) {
124 }
else if (!got_minute) {
128 }
else if (!got_second) {
142 bool matched =
false;
145 for (i = 0; i < num_weekdays && !matched; i++) {
146 if (token == weekdays[i]) {
156 for (i = 0; i < num_months && !matched; i++) {
157 if (token == months[i]) {
167 if (!matched && token ==
"Gmt") {
177 token = get_token(format, pos);
181 if (!(got_month && got_day && got_year && got_hour && got_minute)) {
186 if (t.tm_year < 100) {
189 time_t
now = time(
nullptr);
190 struct tm *tp = gmtime(&
now);
191 t.tm_year += 100 * (tp->tm_year / 100);
192 if (t.tm_year - tp->tm_year > 50) {
196 }
else if (t.tm_year < 1900) {
204 if (!((t.tm_mon >= 0 && t.tm_mon < num_months) &&
205 (t.tm_mday >= 1 && t.tm_mday <= 31) &&
206 (t.tm_hour >= 0 && t.tm_hour < 60) &&
207 (t.tm_min >= 0 && t.tm_min < 60) &&
208 (t.tm_sec >= 0 && t.tm_sec < 62) )) {
223 if (_time != (time_t)-1) {
225#if defined(IS_FREEBSD)
226 time_t
now = time(
nullptr);
227 struct tm *tp = localtime(&
now);
228 _time -= tp->tm_gmtoff;
231 _get_timezone(&timezone);
234 extern long int timezone;