diff options
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 492238198..9403d6d5a 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -6090,18 +6090,19 @@ irc_protocol_parse_time (const char *time) { time_t time_value, time_msg, time_gm, time_local; struct tm tm_date, tm_date_gm, tm_date_local; + long value; + char *time2, *pos, *error; if (!time || !time[0]) return 0; time_value = 0; - /* initialize structure, because strptime does not do it */ - memset (&tm_date, 0, sizeof (struct tm)); - if (strchr (time, '-')) { /* date is with ISO 8601 format: "2012-11-24T07:41:02.018Z" */ + /* initialize structure, because strptime does not do it */ + memset (&tm_date, 0, sizeof (struct tm)); if (strptime (time, "%Y-%m-%dT%H:%M:%S", &tm_date)) { if (tm_date.tm_year > 0) @@ -6118,10 +6119,19 @@ irc_protocol_parse_time (const char *time) else { /* date is with timestamp format: "1353403519.478" */ - if (strptime (time, "%s", &tm_date)) + time2 = strdup (time); + if (time2) { - if (tm_date.tm_year > 0) - time_value = mktime (&tm_date); + pos = strchr (time2, '.'); + if (pos) + pos[0] = '\0'; + pos = strchr (time2, ','); + if (pos) + pos[0] = '\0'; + value = strtol (time2, &error, 10); + if (error && !error[0] && (value >= 0)) + time_value = (int)value; + free (time2); } } |