mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
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:
parent
798336be99
commit
797780c433
4 changed files with 27 additions and 11 deletions
|
@ -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>
|
2011-01-01 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||||
|
|
||||||
* Source/NSLocale.m: Fixed typos found by testsuite.
|
* Source/NSLocale.m: Fixed typos found by testsuite.
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||||
|
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
|
#include <Foundation/NSGeometry.h>
|
||||||
|
|
||||||
@class NSDate;
|
@class NSDate;
|
||||||
@class NSCalendar;
|
@class NSCalendar;
|
||||||
|
|
|
@ -137,13 +137,15 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
|
||||||
+ (id) currentCalendar
|
+ (id) currentCalendar
|
||||||
{
|
{
|
||||||
NSCalendar *result = nil;
|
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 AUTORELEASE(result);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCalendarIdentifier: (NSString *) string
|
- (id) initWithCalendarIdentifier: (NSString *) string
|
||||||
|
@ -351,8 +353,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
|
||||||
#if GS_USE_ICU == 1
|
#if GS_USE_ICU == 1
|
||||||
[self _openCalendar];
|
[self _openCalendar];
|
||||||
return ucal_getAttribute (_cal, UCAL_FIRST_DAY_OF_WEEK);
|
return ucal_getAttribute (_cal, UCAL_FIRST_DAY_OF_WEEK);
|
||||||
#endif
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFirstWeekday: (NSUInteger) weekday
|
- (void) setFirstWeekday: (NSUInteger) weekday
|
||||||
|
@ -360,8 +363,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
|
||||||
#if GS_USE_ICU == 1
|
#if GS_USE_ICU == 1
|
||||||
[self _openCalendar];
|
[self _openCalendar];
|
||||||
ucal_setAttribute (_cal, UCAL_FIRST_DAY_OF_WEEK, (int32_t)weekday);
|
ucal_setAttribute (_cal, UCAL_FIRST_DAY_OF_WEEK, (int32_t)weekday);
|
||||||
#endif
|
#else
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger) minimumDaysInFirstWeek
|
- (NSUInteger) minimumDaysInFirstWeek
|
||||||
|
@ -369,8 +373,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
|
||||||
#if GS_USE_ICU == 1
|
#if GS_USE_ICU == 1
|
||||||
[self _openCalendar];
|
[self _openCalendar];
|
||||||
return ucal_getAttribute (_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK);
|
return ucal_getAttribute (_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK);
|
||||||
#endif
|
#else
|
||||||
return 1;
|
return 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMinimumDaysInFirstWeek: (NSUInteger) mdw
|
- (void) setMinimumDaysInFirstWeek: (NSUInteger) mdw
|
||||||
|
@ -378,8 +383,9 @@ static UCalendarDateFields _NSCalendarUnitToDateField (NSCalendarUnit unit)
|
||||||
#if GS_USE_ICU == 1
|
#if GS_USE_ICU == 1
|
||||||
[self _openCalendar];
|
[self _openCalendar];
|
||||||
ucal_setAttribute (_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, (int32_t)mdw);
|
ucal_setAttribute (_cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, (int32_t)mdw);
|
||||||
#endif
|
#else
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTimeZone *) timeZone
|
- (NSTimeZone *) timeZone
|
||||||
|
|
|
@ -819,7 +819,7 @@ static NSRecursiveLock *classLock = nil;
|
||||||
|
|
||||||
localeId = [NSString stringWithUTF8String: cLocaleId];
|
localeId = [NSString stringWithUTF8String: cLocaleId];
|
||||||
#else
|
#else
|
||||||
localeId = string;
|
localeId = [NSLocale canonicalLocaleIdentifierFromString: string];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[classLock lock];
|
[classLock lock];
|
||||||
|
@ -933,7 +933,10 @@ static NSRecursiveLock *classLock = nil;
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone *) zone
|
- (id) copyWithZone: (NSZone *) zone
|
||||||
{
|
{
|
||||||
|
if (NSShouldRetainWithZone(self, zone))
|
||||||
return RETAIN(self);
|
return RETAIN(self);
|
||||||
|
else
|
||||||
|
return NSCopyObject(self, 0, zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue