Commits

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)

NSCalendarDate+ISO8601Parsing.h

  *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.

NSCalendarDate+ISO8601Parsing.m

 #ifndef DEFAULT_TIME_SEPARATOR
 #	define DEFAULT_TIME_SEPARATOR ':'
 #endif
+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;
 		dateOnly
 	} 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];
 }
 
 @end
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.