From d8804c699dd784be7e7840e6ff4b19eee72c5b65 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 30 Jan 2013 08:40:27 -0500 Subject: [PATCH] Format birthday on contact card --- NEWS | 1 + UI/Contacts/UIxContactView.m | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index adfa28f64..20a6ba973 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ Enhancements - updated Czech translation + - birthday is now properly formatted in addressbook module Bug fixes - fixed handling of groups with spaces in their UID diff --git a/UI/Contacts/UIxContactView.m b/UI/Contacts/UIxContactView.m index 1c0e55dd6..392aabdaf 100644 --- a/UI/Contacts/UIxContactView.m +++ b/UI/Contacts/UIxContactView.m @@ -30,6 +30,9 @@ #import #import +#import +#import +#import #import #import "UIxContactView.h" @@ -612,7 +615,23 @@ - (NSString *) bday { - return [self _cardStringWithLabel: @"Birthday:" value: [card bday]]; + NSString *bday, *value; + NSCalendarDate *date; + SOGoDateFormatter *dateFormatter; + + bday = [card bday]; + if (bday) + { + // Expected format of BDAY is YYYY[-]MM[-]DD + value = [bday stringByReplacingString: @"-" withString: @""]; + date = [NSCalendarDate dateFromShortDateString: value + andShortTimeString: nil + inTimeZone: nil]; + dateFormatter = [[[self context] activeUser] dateFormatterInContext: context]; + bday = [dateFormatter formattedDate: date]; + } + + return [self _cardStringWithLabel: @"Birthday:" value: bday]; } - (NSString *) tz