From 79e383555b355e79857462ecbe2baff68bd2f3b8 Mon Sep 17 00:00:00 2001 From: stefanbidi Date: Fri, 31 Dec 2010 18:13:39 +0000 Subject: [PATCH] Added iOS 4.0 and later methods to NSDateComponents. These methods will probably show up in OS X 10.7 and are easy enough to add now. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31810 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 ++++++- Headers/Foundation/NSCalendar.h | 14 ++++++++++++++ Source/NSCalendar.m | 29 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fe12562cb..c42f18587 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ +2010-12-31 Stefan Bidigaray + + * Headers/Foundation/NSCalendar.h: + * Source/NSCalendar.m: Added iOS 4.0 and later methods to NSDateComponents. + 2010-12-31 Stefan Bidigaray * Resources/GNUmakefile: * Resources/Languages/Locale.canonical: Added mapping to go from long - locale identifiers to short identifiers used by ICU. + locale identifiers to the shorter identifiers used by ICU. * Source/NSLocale.m: Implemented -canonical* and -preferredLanaguges methods. 2010-12-31 14:03 David Chisnall diff --git a/Headers/Foundation/NSCalendar.h b/Headers/Foundation/NSCalendar.h index 79af79854..7fbe84412 100644 --- a/Headers/Foundation/NSCalendar.h +++ b/Headers/Foundation/NSCalendar.h @@ -83,6 +83,12 @@ enum NSInteger _weekday; NSInteger _weekdayOrdinal; NSInteger _quarter; +// FIXME: In reality these are only available on iOS > 4. Will probably show +// up in OS X 10.7. +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) + NSCalendar *_cal; + NSTimeZone *_tz; +#endif } - (NSInteger) day; @@ -112,6 +118,14 @@ enum - (NSInteger) quarter; - (void) setQuarter: (NSInteger) v; #endif + +// FIXME: In reality these are only available on iOS > 4. +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) +- (NSCalendar *) calendar; +- (NSTimeZone *) timeZone; +- (void) setCalendar: (NSCalendar *) cal; +- (void) setTimeZone: (NSTimeZone *) tz; +#endif @end diff --git a/Source/NSCalendar.m b/Source/NSCalendar.m index a347e0def..0db1d2a3c 100644 --- a/Source/NSCalendar.m +++ b/Source/NSCalendar.m @@ -390,6 +390,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit) _week = NSUndefinedDateComponent; _weekday = NSUndefinedDateComponent; _weekdayOrdinal = NSUndefinedDateComponent; +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) + _quarter = NSUndefinedDateComponent; +#endif return self; } @@ -449,6 +452,16 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit) return _year; } +- (NSCalendar *) calendar +{ + return _cal; +} + +- (NSTimeZone *) timeZone +{ + return _tz; +} + - (void) setDay: (NSInteger) v @@ -506,6 +519,22 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit) _year = v; } +- (void) setCalendar: (NSCalendar *) cal +{ + if (_cal) + RELEASE(_cal); + + _cal = RETAIN(cal); +} + +- (void) setTimeZone: (NSTimeZone *) tz +{ + if (_tz) + RELEASE(_tz); + + _tz = RETAIN(tz); +} + - (id) copyWithZone: (NSZone*)zone { if (NSShouldRetainWithZone(self, zone))