--- a/src/rsstool.c 2010-04-24 09:23:42.000000000 -0400 +++ b/src/rsstool.c 2020-11-23 23:34:04.000000000 -0500 @@ -95,6 +95,7 @@ char buf2[MAXBUFSIZE]; const char *p = NULL; FILE *fh = NULL; + tzset (); #if 0 st_property_t props[] = { {NULL, NULL, NULL} --- a/src/misc/misc.c 2020-11-23 23:35:10.988554332 -0500 +++ b/src/misc/misc.c 2020-11-24 00:32:19.000000000 -0500 @@ -145,22 +145,24 @@ { int i = 0; char y[100], m[100], d[100]; - char h[100], min[100]; -// char sec[100]; + char h[100], min[100], sec[100]; + signed char zp; + char zh[3], zmin[3]; struct tm time_tag; time_t t = time (0); + extern long timezone; const char *month_s[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; - *y = *m = *d = *h = *min = 0; + *y = *m = *d = *h = *min = *zh = *zmin = 0; - if (s[10] == 'T') // YYYY-MM-DDT00:00+00:00 + if (s[10] == 'T') // YYYY-MM-DDT00:00:00[Z|[+|-]00:00] { - sscanf (s, " %4s-%2s-%2sT%2s:%2s", y, m, d, h, min); + sscanf (s, "%4s-%2s-%2sT%2s:%2s:%2s%c%2s:%2s", y, m, d, h, min, sec, &zp, zh, zmin); } - else if (s[3] == ',' && s[4] == ' ') // Mon, 31 Jul 2006 15:05:00 GMT + else if (s[3] == ',' && s[4] == ' ') // Mon, 31 Jul 2006 15:05:00 -0000 { - sscanf (s + 5, "%2s %s %4s %2s:%2s", d, m, y, h, min); + sscanf (s + 5, "%2s %s %4s %2s:%2s:%2s %c%2s%2s", d, m, y, h, min, sec, &zp, zh, zmin); for (i = 0; month_s[i]; i++) if (!strcasecmp (m, month_s[i])) @@ -178,6 +180,13 @@ // sscanf (s, " %4s%2s%2sT", y, m, d); } + if (zp == '-') + zp = -1; + else if (zp == '+' || zp == 'Z') + zp = 1; + else + zp = 0; + memset (&time_tag, 0, sizeof (struct tm)); if (*y) @@ -187,9 +196,12 @@ if (*d) time_tag.tm_mday = strtol (d, NULL, 10); if (*h) - time_tag.tm_hour = strtol (h, NULL, 10); + time_tag.tm_hour = strtol (h, NULL, 10) - zp * atoi (zh); if (*min) - time_tag.tm_min = strtol (min, NULL, 10); + time_tag.tm_min = strtol (min, NULL, 10) - zp * atoi (zmin); + + // offset the current UTC time_tag into localtime + time_tag.tm_sec -= timezone; t = mktime (&time_tag);