omz / AppSales-Mobile

App Sales allows iPhone and Mac App Store developers to download and analyze their daily and weekly sales reports from iTunes Connect.
http://omz-software.com
1.89k stars 407 forks source link

2012 Fiscal calendar calculation is wrong for this year #192

Open EnlightenedMike opened 12 years ago

EnlightenedMike commented 12 years ago

Hello, the ITC Apples 2012 fiscal year calendar has 5 weeks in December, not 4. This seems to be an exception.

Anyone got an idea other the a "hack" in the AppleFiscalCalendar.m looking for the period exception.

October and December have 5 weeks,

DerAndereAndi commented 12 years ago

Exceptions are "hacks" :)

I did this in line 37:

NSDate *nextDate;
if (period == 50)
    nextDate = [calendar dateByAddingComponents:components5Weeks toDate:currentDate options:0];
else
    nextDate = [calendar dateByAddingComponents:((period % 3 == 0) ? components5Weeks : components4Weeks) toDate:currentDate options:0];
EnlightenedMike commented 12 years ago

Yes, thanks... Same here, Looks like every year that has 29 days in February has a 5 week December.

Thanks Again and Happy New Year...

finder39 commented 12 years ago

Thanks!

kashifhisam commented 12 years ago

So, a more generalized approach would be to use following for line 37 in AppleFiscalCalendar.m:

NSDate *nextDate = [calendar dateByAddingComponents:((period % 3 == 0) || (period % 50 == 0) ? 
    components5Weeks : components4Weeks) toDate:currentDate options:0];
pilotmoon commented 12 years ago

Thanks folks. I pulled in the fix from your repo, Kerni. I can confirm the fix works for me.