aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ical.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ical.c b/src/ical.c
index 16281e6..d6ea90a 100644
--- a/src/ical.c
+++ b/src/ical.c
@@ -510,6 +510,7 @@ static long ical_datetime2long(char *datestr, ical_vevent_e * type)
static long ical_durtime2long(char *timestr)
{
char *p;
+ int bytes_read;
unsigned hour = 0, min = 0, sec = 0;
if ((p = strchr(timestr, 'T')) == NULL)
@@ -517,16 +518,24 @@ static long ical_durtime2long(char *timestr)
p++;
if (strchr(p, 'H')) {
- if (sscanf(p, "%uH%uM%uS", &hour, &min, &sec) != 3)
+ if (sscanf(p, "%uH%n", &hour, &bytes_read) != 1)
return 0;
- } else if (strchr(p, 'M')) {
- if (sscanf(p, "%uM%uS", &min, &sec) != 2)
+ p += bytes_read;
+ }
+ if (strchr(p, 'M')) {
+ if (sscanf(p, "%uM%n", &min, &bytes_read) != 1)
return 0;
- } else if (strchr(p, 'S')) {
- if (sscanf(p, "%uS", &sec) != 1)
+ p += bytes_read;
+ }
+ if (strchr(p, 'S')) {
+ if (sscanf(p, "%uM%n", &sec, &bytes_read) != 1)
return 0;
+ p += bytes_read;
}
+ if (hour == 0 && min == 0 && sec == 0)
+ return 0;
+
return hour * HOURINSEC + min * MININSEC + sec;
}