Create a new NSCalendar
For now you can of course go for it, but I suspect NSCalendar
subclassing is tricky. This is a helpless bridging, which complicates things; intertwines with NSLocale, which complicates things; it is initialized with identifiers, not a subclass, which complicates things; and gives no indication of what methods are its primitives, which ... complicates things ...
Do you need a subclass to connect to your existing architecture? Otherwise, it would be easiest to create an object from scratch with a similar interface. You can use NSGregorianCalendar
to do most of the work for you and just offset the date for the required days before calculating the date components. You will need special logic for 1700, 1800 and 1900 (and of course 2100, etc.), since it NSGregorianCalendar
won't let you create date components for leap days in those years, but this is still arguably easier than the whole component component calculation manually.
Just wondering what was the purpose of such a calendar?
source to share