NSChineseCalendar
NSChineseCalendar
- Subject: NSChineseCalendar
- From: Antonio Ferraioli <email@hidden>
- Date: Tue, 12 Sep 2006 00:27:14 +0200
Hello,
I'm trying to use the NSCalendar class,
using different Calendar Identifiers
everything seems to work, except for the NSChineseCalendar
which returns all NSDateComponents with 0 values
here is an example, can you tell me what I'm doing wrong ?
- (void) testCalendars
{
// I allocate all calendars available in the documentation
int unitFlags = NSEraCalendarUnit | NSYearCalendarUnit |
NSMonthCalendarUnit | NSDayCalendarUnit |
NSHourCalendarUnit | NSMinuteCalendarUnit |
NSSecondCalendarUnit | NSWeekCalendarUnit |
NSWeekdayCalendarUnit |
NSWeekdayOrdinalCalendarUnit;
NSCalendar *gregorianCalendar = [[[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSCalendar *japaneseCalendar = [[[NSCalendar alloc]
initWithCalendarIdentifier:NSJapaneseCalendar] autorelease];
NSCalendar *buddhistCalendar = [[[NSCalendar alloc]
initWithCalendarIdentifier:NSBuddhistCalendar] autorelease];
NSCalendar *chineseCalendar = [[[NSCalendar alloc]
initWithCalendarIdentifier:NSChineseCalendar] autorelease];
// I get the current date
NSDate *currentDate = [NSDate date];
// For every allocated calendar log the currentDate's components
NSDateComponents *dc = nil;
// gregorian - WORKS - date components are printed in the log with
non 0 values
dc = [gregorianCalendar components:unitFlags fromDate:currentDate];
NSLog(@"era:%ld year:%ld month:%ld day:%ld week:%ld weekday:%ld
weekdayOrdinal:%ld",
[dc era], [dc year], [dc month], [dc day], [dc week], [dc
weekday], [dc weekdayOrdinal]);
// japanese - WORKS - date components are printed in the log with
non 0 values
dc = [japaneseCalendar components:unitFlags fromDate:currentDate];
NSLog(@"era:%ld year:%ld month:%ld day:%ld week:%ld weekday:%ld
weekdayOrdinal:%ld",
[dc era], [dc year], [dc month], [dc day], [dc week], [dc
weekday], [dc weekdayOrdinal]);
// buddhist - WORKS - date components are printed in the log with
non 0 values
dc = [buddhistCalendar components:unitFlags fromDate:currentDate];
NSLog(@"era:%ld year:%ld month:%ld day:%ld week:%ld weekday:%ld
weekdayOrdinal:%ld",
[dc era], [dc year], [dc month], [dc day], [dc week], [dc
weekday], [dc weekdayOrdinal]);
// chinese - FAILS - returns all date compoents with 0 value
dc = [chineseCalendar components:unitFlags fromDate:currentDate];
NSLog(@"era:%ld year:%ld month:%ld day:%ld week:%ld weekday:%ld
weekdayOrdinal:%ld",
[dc era], [dc year], [dc month], [dc day], [dc week], [dc
weekday], [dc weekdayOrdinal]);
}
thank you for your help
antonio ferraioli
www.onmadesoft.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden