diff --git a/lib/ical/time.js b/lib/ical/time.js index 5cfd2cbd..7c0b000d 100644 --- a/lib/ical/time.js +++ b/lib/ical/time.js @@ -1150,11 +1150,24 @@ * @return {ICAL.Time} The date/time instance */ ICAL.Time.fromString = function fromString(aValue, aProperty) { - if (aValue.length > 10) { - return ICAL.Time.fromDateTimeString(aValue, aProperty); - } else { - return ICAL.Time.fromDateString(aValue); + let useDateOnly = true; + let result; + + try { + if (aValue.length > 10) { + result = ICAL.Time.fromDateTimeString(aValue, aProperty); + // If we arrive here, parsing worked, we can skip the fallback. + useDateOnly = false; + } + } catch (e) {} + + if (useDateOnly) { + // Either the input is short, or parsing the long string failed, + // fall back to using the date, only. + result = ICAL.Time.fromDateString(aValue); } + + return result; }; /**