Anonymous committed b94ada4

Made this an external variable, so that you can pass in the default separator.
Also added an assertion. timeSep should never be NUL.

Comments (0)

Files changed (2)


  *A full list of these extensions is in the README file.
+//The default separator for time values. Currently, this is ':'.
+extern unichar ISO8601DefaultTimeSeparatorCharacter;
 @interface NSCalendarDate(ISO8601Parsing)
 //This method is the one that does all the work. All the others are convenience methods.


+unichar ISO8601DefaultTimeSeparatorCharacter = DEFAULT_TIME_SEPARATOR;
 static unsigned read_segment(const unsigned char *str, const unsigned char **next, unsigned *out_num_digits) {
 	unsigned num_digits = 0U;
 	} dateSpecification = monthAndDate;
-	if(strict) timeSep = DEFAULT_TIME_SEPARATOR;
+	if(strict) timeSep = ISO8601DefaultTimeSeparatorCharacter;
+	NSParameterAssert(timeSep != '\0', @"Time separator must not be NUL.");
 	BOOL isValidDate = ([str length] > 0U);
 	NSTimeZone *timeZone = nil;
 	return [self calendarDateWithString:str strictly:strict getRange:NULL];
 + (NSCalendarDate *)calendarDateWithString:(NSString *)str strictly:(BOOL)strict getRange:(out NSRange *)outRange {
-	return [self calendarDateWithString:str strictly:strict timeSeparator:DEFAULT_TIME_SEPARATOR getRange:NULL];
+	return [self calendarDateWithString:str strictly:strict timeSeparator:ISO8601DefaultTimeSeparatorCharacter getRange:NULL];
 + (NSCalendarDate *)calendarDateWithString:(NSString *)str timeSeparator:(unichar)timeSep getRange:(out NSRange *)outRange {
 	return [self calendarDateWithString:str strictly:NO timeSeparator:timeSep getRange:NULL];
 + (NSCalendarDate *)calendarDateWithString:(NSString *)str getRange:(out NSRange *)outRange {
-	return [self calendarDateWithString:str strictly:NO timeSeparator:DEFAULT_TIME_SEPARATOR getRange:outRange];
+	return [self calendarDateWithString:str strictly:NO timeSeparator:ISO8601DefaultTimeSeparatorCharacter getRange:outRange];