Commits

Anonymous committed f2ce295

Don't try to support fractional minutes (12:05.5 == 12:05:30) when the time separator is '.' or ','.

  • Participants
  • Parent commits 739e52b

Comments (0)

Files changed (1)

File NSCalendarDate+ISO8601Parsing.m

 		}
 		value = int_value;
 
-		if((*str == ',') || (*str == '.')) {
+		if(((*str == ',') || (*str == '.'))) {
 			++str;
 
 			register double multiplier, multiplier_multiplier;
 				hour = read_segment_2digits(ch, &ch);
 				if(*ch == timeSep) {
 					++ch;
-					minute = read_double(ch, &ch);
-					second = modf(minute, &minute);
-					if(second > DBL_EPSILON)
-						second *= 60.0; //Convert fraction (e.g. .5) into seconds (e.g. 30).
-					else if(*ch == timeSep) {
-						++ch;
-						second = read_double(ch, &ch);
+					if((timeSep == ',') || (timeSep == '.')) {
+						//We can't do fractional minutes when '.' is the segment separator.
+						//Only allow whole minutes and whole seconds.
+						minute = read_segment_2digits(ch, &ch);
+						if(*ch == timeSep) {
+							++ch;
+							second = read_segment_2digits(ch, &ch);
+						}
+					} else {
+						//Allow a fractional minute.
+						//If we don't get a fraction, look for a seconds segment.
+						//Otherwise, the fraction of a minute is the seconds.
+						minute = read_double(ch, &ch);
+						second = modf(minute, &minute);
+						if(second > DBL_EPSILON)
+							second *= 60.0; //Convert fraction (e.g. .5) into seconds (e.g. 30).
+						else if(*ch == timeSep) {
+							++ch;
+							second = read_double(ch, &ch);
+						}
 					}
 				}