I am writing a program that shows the current years sales from the beginning of the fiscal year to the current date, compared to the same date range of the year before.
My question is, what efforts do I need to take for leap year?
UPDATE:
OK they want it like I said (compare last year up to same date) but if today is non leap year and last year is and today is feb 28th compare to last year up to 29th. Or if today is Feb 29th compare to last year up to 28th.
This strikes me as a business decision. Depending on the type of business, that extra day may not matter. Otherwise, I suppose you could treat is as "first n days of the year" rather than "Jan 1 through X".
Surely that depends on what the business wants you to do. Isn't this a question that should be answered by an accountant?
Here's an idea, but like others have said it might be based on your specific domain.
So for example
You can compare this directly to a similar calculation for 2008,
You could scale down the leap year values to take the extra day into account.
So if you compare, say, the 1st of September of a regular year with the 1st of September of a leap year you would do:
This should really be in the specification, though.