152 if ((s = (
char *)strchr(str,
','))) {
154 while (*s && *s ==
' ')
156 if (strchr(s,
'-')) {
157 DBG(cerr <<
"Format...... Weekday, 00-Mon-00 00:00:00 GMT" << endl);
159 DBG(cerr <<
"ERROR....... Not a valid time format \"" << s <<
"\"" << endl);
162 tm.tm_mday = strtol(s, &s, 10);
163 tm.tm_mon = make_month(s, &s);
165 tm.tm_year = strtol(s, &s, 10);
166 tm.tm_hour = strtol(s, &s, 10);
168 tm.tm_min = strtol(s, &s, 10);
170 tm.tm_sec = strtol(s, &s, 10);
172 DBG(cerr <<
"Format...... Wkd, 00 Mon 0000 00:00:00 GMT" << endl);
174 DBG(cerr <<
"ERROR....... Not a valid time format \"" << s <<
"\"" << endl);
177 tm.tm_mday = strtol(s, &s, 10);
178 tm.tm_mon = make_month(s, &s);
179 tm.tm_year = strtol(s, &s, 10) - 1900;
180 tm.tm_hour = strtol(s, &s, 10);
182 tm.tm_min = strtol(s, &s, 10);
184 tm.tm_sec = strtol(s, &s, 10);
186 }
else if (isdigit((
int)*str)) {
187 if (strchr(str,
'T')) {
188 DBG(cerr <<
"Format...... YYYY.MM.DDThh:mmStzWkd" << endl);
190 while (*s && *s ==
' ')
193 DBG(cerr <<
"ERROR....... Not a valid time format \"" << s <<
"\"" << endl);
196 tm.tm_year = strtol(s, &s, 10) - 1900;
198 tm.tm_mon = strtol(s, &s, 10);
201 tm.tm_mday = strtol(s, &s, 10);
203 tm.tm_hour = strtol(s, &s, 10);
205 tm.tm_min = strtol(s, &s, 10);
207 tm.tm_sec = strtol(s, &s, 10);
209 t = expand ? time(NULL) + atol(str) : atol(str);
213 DBG(cerr <<
"Format...... Wkd Mon 00 00:00:00 0000 GMT" << endl);
215 while (*s && *s ==
' ')
217 DBG(cerr <<
"Trying...... The Wrong time format: " << s << endl);
219 DBG(cerr <<
"ERROR....... Not a valid time format \"" << s <<
"\"" << endl);
222 tm.tm_mon = make_month(s, &s);
223 tm.tm_mday = strtol(s, &s, 10);
224 tm.tm_hour = strtol(s, &s, 10);
226 tm.tm_min = strtol(s, &s, 10);
228 tm.tm_sec = strtol(s, &s, 10);
229 tm.tm_year = strtol(s, &s, 10) - 1900;
232 if (tm.tm_sec < 0 || tm.tm_sec > 59 || tm.tm_min < 0 || tm.tm_min > 59 || tm.tm_hour < 0 || tm.tm_hour > 23 ||
233 tm.tm_mday < 1 || tm.tm_mday > 31 || tm.tm_mon < 0 || tm.tm_mon > 11 || tm.tm_year < 70 ||
235 DBG(cerr <<
"ERROR....... Parsed illegal time" << endl);
242#if defined(HAVE_TIMEGM)
244#elif defined(HAVE_MKTIME)
245 return mktime(&tm) + offset_from_utc();
247#error "Neither mktime nor timegm defined"
268#if defined(_REENTRANT) || defined(SOLARIS)
269 struct tm loctime {};
270 localtime_r(calendar, &loctime);
273 struct tm *loctime = localtime(calendar);
277#if defined(_REENTRANT) || defined(SOLARIS)
279 gmtime_r(calendar, &gmt);
282 struct tm *gmt = gmtime(calendar);
290#if defined(_REENTRANT)
291 struct tm loctime {};
292 localtime_r(calendar, &loctime);
293 snprintf(buf,
MAX_TIME_STR_LEN,
"%s, %02d %s %04d %02d:%02d:%02d", wkdays[loctime.tm_wday], loctime.tm_mday,
294 months[loctime.tm_mon], loctime.tm_year + 1900, loctime.tm_hour, loctime.tm_min, loctime.tm_sec);
296 struct tm *loctime = localtime(calendar);
299 snprintf(buf,
MAX_TIME_STR_LEN,
"%s, %02d %s %04d %02d:%02d:%02d", wkdays[loctime->tm_wday], loctime->tm_mday,
300 months[loctime->tm_mon], loctime->tm_year + 1900, loctime->tm_hour, loctime->tm_min, loctime->tm_sec);
303#if defined(_REENTRANT) || defined(SOLARIS)
305 gmtime_r(calendar, &gmt);
306 snprintf(buf,
MAX_TIME_STR_LEN,
"%s, %02d %s %04d %02d:%02d:%02d GMT", wkdays[gmt.tm_wday], gmt.tm_mday,
307 months[gmt.tm_mon], gmt.tm_year + 1900, gmt.tm_hour, gmt.tm_min, gmt.tm_sec);
309 struct tm *gmt = gmtime(calendar);
312 snprintf(buf,
MAX_TIME_STR_LEN,
"%s, %02d %s %04d %02d:%02d:%02d GMT", wkdays[gmt->tm_wday], gmt->tm_mday,
313 months[gmt->tm_mon], gmt->tm_year + 1900, gmt->tm_hour, gmt->tm_min, gmt->tm_sec);