Source/AIChatLog.m
branchadium-1.5.10
changeset 5844 aed198ae15cb
parent 5750 dad5f3048dc3
child 5862 a97833ab0faf
equal deleted inserted replaced
5843:9b4717820ead 5844:aed198ae15cb
   306 {
   306 {
   307 	ISO8601DateFormatter *formatter = [[[ISO8601DateFormatter alloc] init] autorelease];
   307 	ISO8601DateFormatter *formatter = [[[ISO8601DateFormatter alloc] init] autorelease];
   308 	formatter.timeSeparator = '.';
   308 	formatter.timeSeparator = '.';
   309 	NSRange openParenRange, closeParenRange;
   309 	NSRange openParenRange, closeParenRange;
   310 	
   310 	
   311 	if ([fileName hasSuffix:@".chatlog"] && (openParenRange = [fileName rangeOfString:@"(" options:NSBackwardsSearch]).location != NSNotFound) {
   311 	if ((openParenRange = [fileName rangeOfString:@"(" options:NSBackwardsSearch]).location != NSNotFound) {
   312 		openParenRange = NSMakeRange(openParenRange.location, [fileName length] - openParenRange.location);
   312 		openParenRange = NSMakeRange(openParenRange.location, [fileName length] - openParenRange.location);
   313 		if ((closeParenRange = [fileName rangeOfString:@")" options:0 range:openParenRange]).location != NSNotFound) {
   313 		if ((closeParenRange = [fileName rangeOfString:@")" options:0 range:openParenRange]).location != NSNotFound) {
   314 			//Add and subtract one to remove the parenthesis
   314 			//Add and subtract one to remove the parenthesis
   315 			NSString *dateString = [fileName substringWithRange:NSMakeRange(openParenRange.location + 1, (closeParenRange.location - openParenRange.location))];
   315 			NSString *dateString = [fileName substringWithRange:NSMakeRange(openParenRange.location + 1, (closeParenRange.location - openParenRange.location))];
   316 			return [formatter dateFromString:dateString];
   316 			// Fix really old chatlogs which use "(2005|05|07)".
       
   317 			return [formatter dateFromString:[dateString stringByReplacingOccurrencesOfString:@"|" withString:@"-"]];
   317 		}
   318 		}
   318 	}
   319 	}
   319 	return nil;
   320 	return nil;
   320 }
   321 }
   321 
   322