I use some code to translate a list of dates into different sections by month:
- (NSString *) calculateSectionPeriod{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSCalendarUnitYear | NSCalendarUnitMonth) fromDate: [self userDate]];
NSString *tmp = [NSString stringWithFormat:@"%ld", ([components year] * 1000) + [components month]];
NSLog(@"Section period = %@", tmp);
return tmp;
}
The userDate is set from a NSDatePicker.
In most cases, this prints strings like "2015006" (June 2015) or "2017011" (November 2017). However, in some cases, for some users of my app, it ends up printing "15003" (and ends up causing some problems in Core Data). This is coming from their own reports, and I haven't been able to reproduce the issue on my own device, but it's clear to me that the problem is with this code.
Any reason where the 'year' component would print '15' instead of of '2015'? Is it by region or some language settings? I've tried setting different regions and languages, but haven't been able to reproduce the problem myself.