Commits

Anonymous committed f2ce295

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

Comments (0)

Files changed (1)

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);
+						}
 					}
 				}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.