Fix Adium not storing timestamps with messages. Setting NSDateFormatterBehavior10_4 was not the solution, all included time format strings are now 10.4 style. adium-1.5.9
authorThijs Alkemade <me@thijsalkema.de>
Wed, 30 Oct 2013 18:34:07 +0100
branchadium-1.5.9
changeset 5749 1521cab508bf
parent 5726 44b2eacffae5
child 5750 dad5f3048dc3
Fix Adium not storing timestamps with messages. Setting NSDateFormatterBehavior10_4 was not the solution, all included time format strings are now 10.4 style.

Message styles can still contain old style format strings, causing _NSDateFormatter_Log_New_Methods_On_Old_Formatters to be hit. We probably need to update the included ones and deprecate their usage in Adium.
Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Unparsing.m
Other/Adium Spotlight Importer/GetMetadataForFile.m
Plugins/WebKit Message View/AIWebkitMessageViewStyle.m
--- a/Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Unparsing.m	Wed Oct 23 14:22:49 2013 -0500
+++ b/Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Unparsing.m	Wed Oct 30 18:34:07 2013 +0100
@@ -40,10 +40,10 @@
 #pragma mark Public methods
 
 - (NSString *)ISO8601DateStringWithTime:(BOOL)includeTime timeSeparator:(unichar)timeSep {
-	NSString *dateFormat = [(includeTime ? @"%Y-%m-%dT%H:%M:%S" : @"%Y-%m-%d") prepareDateFormatWithTimeSeparator:timeSep];
-	NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat:dateFormat allowNaturalLanguage:NO];
-	[formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
-	NSString *str = [formatter stringForObjectValue:self];
+	NSString *dateFormat = [(includeTime ? @"yyyy'-'MM'-'dd'T'HH':'mm':'ss" : @"yyyy'-'MM'-'dd") prepareDateFormatWithTimeSeparator:timeSep];
+	NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+	formatter.dateFormat = dateFormat;
+	NSString *str = [formatter stringFromDate:self];
 	[formatter release];
 	if(includeTime) {
 		NSInteger offset = [[self timeZone] secondsFromGMT];
@@ -106,8 +106,8 @@
 
 	NSString *timeString;
 	if(includeTime) {
-		NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat:[@"T%H:%M:%S%z" prepareDateFormatWithTimeSeparator:timeSep] allowNaturalLanguage:NO];
-		[formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+		NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+		formatter.dateFormat = [@"'T'HH':'mm':'ssZ" prepareDateFormatWithTimeSeparator:timeSep];
 		timeString = [formatter stringForObjectValue:self];
 		[formatter release];
 	} else
@@ -118,8 +118,8 @@
 - (NSString *)ISO8601OrdinalDateStringWithTime:(BOOL)includeTime timeSeparator:(unichar)timeSep {
 	NSString *timeString;
 	if(includeTime) {
-		NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat:[@"T%H:%M:%S%z" prepareDateFormatWithTimeSeparator:timeSep] allowNaturalLanguage:NO];
-		[formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+		NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+		formatter.dateFormat = [@"'T'HH':'mm':'ssZ" prepareDateFormatWithTimeSeparator:timeSep];
 		timeString = [formatter stringForObjectValue:self];
 		[formatter release];
 	} else
--- a/Other/Adium Spotlight Importer/GetMetadataForFile.m	Wed Oct 23 14:22:49 2013 -0500
+++ b/Other/Adium Spotlight Importer/GetMetadataForFile.m	Wed Oct 30 18:34:07 2013 +0100
@@ -242,8 +242,8 @@
 			//pick the first author for this.  likely a bad idea
 			if (startDate && [otherAuthors count]) {
 				NSString *toUID = [otherAuthors objectAtIndex:0];
-				NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d" allowNaturalLanguage:NO];
-				[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+				NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+				dateFormatter.dateFormat = @"yyyy'-'MM'-'dd";
 				
 				[attributes setObject:[NSString stringWithFormat:@"%@ on %@",toUID,[dateFormatter stringFromDate:startDate]]
 							   forKey:(NSString *)kMDItemDisplayName];
--- a/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m	Wed Oct 23 14:22:49 2013 -0500
+++ b/Plugins/WebKit Message View/AIWebkitMessageViewStyle.m	Wed Oct 30 18:34:07 2013 +0100
@@ -334,7 +334,6 @@
 	if ([format rangeOfString:@"%"].location != NSNotFound) {
 		/* Support strftime-style format strings, which old message styles may use */
 		timeStampFormatter = [[NSDateFormatter alloc] initWithDateFormat:format allowNaturalLanguage:NO];
-		[timeStampFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
 	} else {
 		timeStampFormatter = [[NSDateFormatter alloc] init];
 		[timeStampFormatter setDateFormat:format];
@@ -853,7 +852,6 @@
 						if ([timeFormat rangeOfString:@"%"].location != NSNotFound) {
 							/* Support strftime-style format strings, which old message styles may use */
 							dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:timeFormat allowNaturalLanguage:NO];
-							[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
 						} else {
 							dateFormatter = [[NSDateFormatter alloc] init];
 							[dateFormatter setDateFormat:timeFormat];
@@ -1273,7 +1271,6 @@
 				if ([timeFormat rangeOfString:@"%"].location != NSNotFound) {
 					/* Support strftime-style format strings, which old message styles may use */
 					dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:timeFormat allowNaturalLanguage:NO];
-					[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
 				} else {
 					dateFormatter = [[NSDateFormatter alloc] init];
 					[dateFormatter setDateFormat:timeFormat];