Fix the missing dates in the chat log viewer for old AdiumHTMLLogs. adium-1.5.10
authorThijs Alkemade <me@thijsalkema.de>
Fri, 21 Feb 2014 13:15:39 +0100
branchadium-1.5.10
changeset 5844 aed198ae15cb
parent 5843 9b4717820ead
child 5845 8adea39f58ed
Fix the missing dates in the chat log viewer for old AdiumHTMLLogs.
Other/Adium Spotlight Importer/GetMetadataForHTMLLog.m
Source/AIChatLog.m
--- a/Other/Adium Spotlight Importer/GetMetadataForHTMLLog.m	Fri Feb 21 12:39:21 2014 +0100
+++ b/Other/Adium Spotlight Importer/GetMetadataForHTMLLog.m	Fri Feb 21 13:15:39 2014 +0100
@@ -30,12 +30,12 @@
 	formatter.timeSeparator = '.';
 	NSRange openParenRange, closeParenRange;
 	
-	if ([pathToFile hasSuffix:@".chatlog"] && (openParenRange = [pathToFile rangeOfString:@"(" options:NSBackwardsSearch]).location != NSNotFound) {
+	if ((openParenRange = [pathToFile rangeOfString:@"(" options:NSBackwardsSearch]).location != NSNotFound) {
 		openParenRange = NSMakeRange(openParenRange.location, [pathToFile length] - openParenRange.location);
 		if ((closeParenRange = [pathToFile rangeOfString:@")" options:0 range:openParenRange]).location != NSNotFound) {
 			//Add and subtract one to remove the parenthesis
 			NSString *dateString = [pathToFile substringWithRange:NSMakeRange(openParenRange.location + 1, (closeParenRange.location - openParenRange.location))];
-			return [formatter dateFromString:dateString];
+			return [formatter dateFromString:[dateString stringByReplacingOccurrencesOfString:@"|" withString:@"-"]];
 		}
 	}
 	return nil;
--- a/Source/AIChatLog.m	Fri Feb 21 12:39:21 2014 +0100
+++ b/Source/AIChatLog.m	Fri Feb 21 13:15:39 2014 +0100
@@ -308,12 +308,13 @@
 	formatter.timeSeparator = '.';
 	NSRange openParenRange, closeParenRange;
 	
-	if ([fileName hasSuffix:@".chatlog"] && (openParenRange = [fileName rangeOfString:@"(" options:NSBackwardsSearch]).location != NSNotFound) {
+	if ((openParenRange = [fileName rangeOfString:@"(" options:NSBackwardsSearch]).location != NSNotFound) {
 		openParenRange = NSMakeRange(openParenRange.location, [fileName length] - openParenRange.location);
 		if ((closeParenRange = [fileName rangeOfString:@")" options:0 range:openParenRange]).location != NSNotFound) {
 			//Add and subtract one to remove the parenthesis
 			NSString *dateString = [fileName substringWithRange:NSMakeRange(openParenRange.location + 1, (closeParenRange.location - openParenRange.location))];
-			return [formatter dateFromString:dateString];
+			// Fix really old chatlogs which use "(2005|05|07)".
+			return [formatter dateFromString:[dateString stringByReplacingOccurrencesOfString:@"|" withString:@"-"]];
 		}
 	}
 	return nil;