Re: Getting an era's beginning date
Re: Getting an era's beginning date
- Subject: Re: Getting an era's beginning date
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 28 Jan 2008 21:31:20 -0700
On Jan 28, 2008, at 9:11 PM, Christopher Nebel wrote:
Realistic or not, they did it. =) I think the Japanese calendar
support was added in Tiger; the era names go back to Taika in 645
AD. I found that I can get at least the year by using something
like this:
jp = [[NSCalendar alloc] initWithCalendarIdentifier:@"japanese"];
components = [NSDateComponents alloc] init];
[components setEra:235]; // Heisei; Taika is 0.
date = [jp dateFromComponents: components]; // date is 1989-01-01
00:00:00 -0800
Notice, however, that the day is wrong. I don't know if that's a
deficiency in my code or in the era data itself.
The date is actually correct. This is why I wanted to know the method
of getting an era's beginning date, because eras, unlike years,
months, and days, can begin and end at any time on a calendar.
In the case of the Japanese calendar, the 235th era is indeed the
Heisei era, but since you didn't specify year & date components,
NSCalendar assumes you meant the first year/month/day in that time
frame. The first year of the Heisei era is 1989, but January 1, 1989
is actually in the Showa (234th) era.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden