I wonder what is the different of NSCalendarIdentifierRepublicOfChina
(NSRepublicOfChinaCalendar
) and NSCalendarIdentifierChinese
(NSChineseCalendar
) but can't find any information from Apple Developer website.
Can anyone help me?
Thanks
From NSLocale Calendar Keys:
NSRepublicOfChinaCalendar
Identifier for the Republic of China (Taiwan) calendar.A Chinese calendar can be created, and you can do calendrical calculations with it, but you should not use it for formatting as the necessary underlying functionality is not working correctly yet.
Available in OS X v10.6 and later.
Deprecated in OS X v10.10.
and
NSChineseCalendar
Identifier for the Chinese calendar.Available in OS X v10.4 and later.
Deprecated in OS X v10.10.
So
NSRepublicOfChinaCalendar
(which has been deprecated in favor of
NSCalendarIdentifierRepublicOfChina
) is for the calendar used in Taiwan.
As I understand it, this is the Minguo calendar and differs from the Gregorian calendar
by a difference of 1911 in the years.
NSChineseCalendar
(which has been deprecated in favor of NSCalendarIdentifierChinese
) is for the traditional Chinese calendar.
The following code prints the current date (January 10, 2015 in the Gregorian calendar) in both those calendars:
let fmt = NSDateFormatter()
fmt.locale = NSLocale(localeIdentifier: "en_US_POSIX")
fmt.dateStyle = .FullStyle
let rocCal = NSCalendar(calendarIdentifier: NSCalendarIdentifierRepublicOfChina)
fmt.calendar = rocCal
println(fmt.stringFromDate(NSDate()))
// Saturday, January 10, 104 Minguo
let chineseCal = NSCalendar(calendarIdentifier: NSCalendarIdentifierChinese)
fmt.calendar = chineseCal
println(fmt.stringFromDate(NSDate()))
// Saturday, Month11 20, 2014(jia-wu)
The latter is the 20th day in the 11th month in the year of the horse (Jia Wu)