Just out of curiosity (as this was the first time I've ever needed to calculate it in Cocoa) -
Is this really the most concise way to calculate the current year?
int thisYear = [[[NSCalendar currentCalendar]
components:NSYearCalendarUnit fromDate:[NSDate date]]
year];
Seems pretty clumsy..
Yes, when I need to get components from a date like the day, month or year, I use NSDateComponents
, fact is dates are clumsy - There are different calendars, time zones, leap years etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With