Re: Getting an era's beginning date
Re: Getting an era's beginning date
- Subject: Re: Getting an era's beginning date
- From: Christopher Nebel <email@hidden>
- Date: Mon, 28 Jan 2008 20:11:33 -0800
On 平成 20/01/28, at 16:39, 慧 松本 wrote:
On 2008/01/29, at 8:49, Nick Zitzmann wrote:
For days, weeks, etc. this is trivial, since they have a universal
start time. But an era can begin and end at any point in time.
These points in time are trivial to figure out on the Gregorian
calendar (the AD era began on January 1, 1), but the Japanese
calendar is a totally different story (the Heisei era began on
January 7, 1989 for example).
I am a Japanese.
"January 7, 1989" is the date that our current emperor was
enthroned. Each emperor had his own eras. Some emperors changed
their eras when a disaster or evil thing had happened.
As our imperial family has continued for more than 2000 years, there
are hundreds of eras in Japanese calendar.
I don't think it is realistic for NSCalendar to have Japanese era
database.
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.
--Chris Nebel
_______________________________________________
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