Say you have a date, 30/03/2017, and you want to find out how many days are within that date from 00/00/0000. I know the days portion and year portion of the date can be expressed as:
cumulativeDays = year * 365 + year / 4 + days;
However, I don't know how to express the cumulative days given by the month portion of the date. I have found that the days in any given month can be given by:
f(x) = 28 + (x + floor(x / 8)) % 2 + 2 % x + 2 * floor(1 / x)
as detailed at the following link, but I can't transform the above formula into a summation of the days in each month. I intend to use a summation formula based upon the above to output the days up to the start of March, i.e. 31 + 28, which would then cover the month portion of the date. Could someone help me with creating this summation formula? I'm struggling with the summation of the mods specifically.
If anyone happens to have a better way of doing this I'm open to suggestions but I'd like the solution to be restricted to a single formula which given the year, month and day will outputs the cumulative days.
To clarify I'm attempting to make a formula to convert a given date, say today 30/03/2017, into days only. I.e. the date 02/01/0003 would be:
years = 3 * 365 + 3 / 4 = 1095
months = 31 (January only)
days = 2
So the cumulative days would then be:
1095 + 31 + 2 = 1128
Please note that I'm using this in a computing context and hence performing integer devision, so
3 / 4 = 0
not
3 / 4 = 0.75