Minor fixes to NSCalendar and NSLocale. Also implemented NSCalendar's +currentCalendar.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31819 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Stefan Bidigaray 2011-01-01 22:20:16 +00:00
parent 798336be99
commit 797780c433
4 changed files with 27 additions and 11 deletions

View file

@ -1,3 +1,9 @@
2011-01-01 Stefan Bidigaray <stefanbidi@gmail.com>
* Headers/Foundation/NSCalendar.h:
* Source/NSLocale.m: Minor fixes.
* Source/NSCalendar.m: Implemented +currentCalendar.
2011-01-01 Stefan Bidigaray <stefanbidi@gmail.com>
* Source/NSLocale.m: Fixed typos found by testsuite.

View file

@ -30,6 +30,7 @@
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
#include <Foundation/NSObject.h>
#include <Foundation/NSGeometry.h>
@class NSDate;
@class NSCalendar;

View file

@ -137,13 +137,15 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
+ (id) currentCalendar
{
NSCalendar *result = nil;
NSLocale *locale;
NSCalendar *cal;
locale = [NSLocale currentLocale];
#if GS_USE_ICU == 1
cal = [[NSLocale currentLocale] objectForKey: NSLocaleCalendar];
result =
[[NSCalendar alloc] initWithCalendarIdentifier: [cal calendarIdentifier]];
#endif
// FIXME
return result;
return AUTORELEASE(result);
}
- (id) initWithCalendarIdentifier: (NSString *) string
@ -351,8 +353,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
#if GS_USE_ICU == 1
[self _openCalendar];
return ucal_getAttribute (_cal, UCAL_FIRST_DAY_OF_WEEK);
#endif
#else
return 0;
#endif
}
- (void) setFirstWeekday: (NSUInteger) weekday
@ -360,8 +363,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
#if GS_USE_ICU == 1
[self _openCalendar];
ucal_setAttribute (_cal, UCAL_FIRST_DAY_OF_WEEK, (int32_t)weekday);
#endif
#else
return;
#endif
}
- (NSUInteger) minimumDaysInFirstWeek
@ -369,8 +373,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
#if GS_USE_ICU == 1
[self _openCalendar];
return ucal_getAttribute (_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK);
#endif
#else
return 1;
#endif
}
- (void) setMinimumDaysInFirstWeek: (NSUInteger) mdw
@ -378,8 +383,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
#if GS_USE_ICU == 1
[self _openCalendar];
ucal_setAttribute (_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, (int32_t)mdw);
#endif
#else
return;
#endif
}
- (NSTimeZone *) timeZone

View file

@ -819,7 +819,7 @@ static NSRecursiveLock *classLock = nil;
localeId = [NSString stringWithUTF8String: cLocaleId];
#else
localeId = string;
localeId = [NSLocale canonicalLocaleIdentifierFromString: string];
#endif
[classLock lock];
@ -933,7 +933,10 @@ static NSRecursiveLock *classLock = nil;
- (id) copyWithZone: (NSZone *) zone
{
return RETAIN(self);
if (NSShouldRetainWithZone(self, zone))
return RETAIN(self);
else
return NSCopyObject(self, 0, zone);
}
@end