All the rest have 31 except February which has 28 unless it is a leap year, in which case it has 29.

Leap years are those where year % 4 == 0 unless year % 100 == 0 but it's still a leap year when year % 400 == 0.

Or in more simple terms (from Wikipedia):

if (year is not exactly divisible by 4) then (it is a common year)
else
if (year is not exactly divisible by 100) then (it is a leap year)
else
if (year is not exactly divisible by 400) then (it is a common year)
else (it is a leap year)

Of course, this only applies to Gregorian calendars, which we use today... :-)

And BTW, years != month/12, unless you are talking about the total number of months beyond or == 12, so you should say:

(months~=total_days/30;), (years=total_months/12;), (day_of_the_month~=total_days%30). Remember the approximate symbol (~). Approximations are good, if you remember to note them, otherwise you are just plain wrong!

Per David W's post, modular arithmetic returns the remainer of a division operation, so 4%2 is the remainder of 4/2 which is 0. If there are 30 days in a month, then if it is the 15th of the month, the remainder of 15/30 is 15, so 15%30 == 15. If we are using the day of the year to determine the month, and day of the month, assuming all months have 30 days, then if the day is 250, the month is 250/30 == 8 with a remainder of 10. So 250%30 == 10. IE, the date would be the 10th of the 9th month (September 8th) as the 8th month (August) is complete.

Hello guys, hope you all fine,,
I have a problem when coding using python and opencv.
My project is to track the ball in model soccer pitch using raspberry pi ...