NSCalendarIdentifierChinese, extracting the current year

Hi,


I am trying to convert a date from Gregorain calendar to Chinese calendar, using NSCalendar, NSDateCompoents and NSCalendarIdentifier.

The conversion works fine, but there is a complication with Year part of the chinese date.


What I get for Gregorain year 2018 is Chinese year 35 (which is okay according to Sexagenary cycle), but the modern chinese calendar system do not use 35 as year. They use the same gregorain calender year (+/- 1 adjusted)


Is there a way to get the modern chinese calendar year from a gregorian date?


NSCalendar *toCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierChinesehttps://developer.apple.com/documentation/foundation/nscalendaridentifier?language=objchttps://developer.apple.com/documentation/foundation/nscalendaridentifier?language=objc];
NSUInteger unitFlags = NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear;
NSDateComponents *toComps = [toCalendar components:unitFlags fromDate:[NSDate date]];

//[toComps year] gives 35 for today's date (Oct 17th, 2018)

Replies

Do you have any solution for this issue?