Commits

boredzo  committed 3817e7f

Merged http://trac.adiumx.com/changeset/16414?format=diff&new=16414 in, with the author's (Graham Booker's) consent to put it under BSD license (see LICENSE.txt in this revision of this directory).

  • Participants
  • Parent commits 8abebd8

Comments (0)

Files changed (1)

File NSCalendarDate+ISO8601Unparsing.m

 #pragma mark Public methods
 
 - (NSString *)ISO8601DateStringWithTime:(BOOL)includeTime {
-	NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat:(includeTime ? @"%Y-%m-%dT%H:%M:%S%z" : @"%Y-%m-%d") allowNaturalLanguage:NO];
+	NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat:(includeTime ? @"%Y-%m-%dT%H:%M:%S" : @"%Y-%m-%d") allowNaturalLanguage:NO];
 	NSString *str = [formatter stringForObjectValue:self];
 	[formatter release];
+	if(includeTime) {
+		int offset = [[self timeZone] secondsFromGMT];
+		offset /= 60;  //bring down to minutes
+		if(offset == 0)
+			str = [str stringByAppendingString:@"Z"];
+		if(offset < 0)
+			str = [str stringByAppendingFormat:@"-%02d:%02d", -offset / 60, offset % 60];
+		else
+			str = [str stringByAppendingFormat:@"+%02d:%02d", offset / 60, offset % 60];
+	}
 	return str;
 }
 /*Adapted from: