Skip navigation.
 
mlRe: Getting an era's beginning date
FROM : Christopher Nebel
DATE : Tue Jan 29 05:11:33 2008

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

Related mailsAuthorDate
mlGetting an era's beginning date Nick Zitzmann Jan 29, 00:49
mlRe: Getting an era's beginning date ? ?? Jan 29, 01:39
mlRe: Getting an era's beginning date Clark Cox Jan 29, 01:45
ml[WORKAROUND] Re: Getting an era's beginning date Nick Zitzmann Jan 29, 02:54
mlRe: Getting an era's beginning date Christopher Nebel Jan 29, 05:11
mlRe: Getting an era's beginning date Nick Zitzmann Jan 29, 05:31
mlRe: Getting an era's beginning date ? ?? Jan 29, 06:01
mlRe: Getting an era's beginning date Christopher Nebel Jan 29, 22:17
mlRe: Getting an era's beginning date Chris Kane Feb 1, 19:41