Quote:
Originally Posted by Old Pedant
Leap year is easy:
Code:
var leap = ( year % 4 ) == 0;
Code looks basically right, but I don't see any need for a switch if done right.
Instead, just have an array of month names and index into the array by the month number.
|
I only see if-else or switch as a viable way of doing it less there is something. The if-else/switch is needed to select the month in general. There is no other place that that month selection takes place and I also have to remove excess days so it fits to the month.
I don't see another way to do this. I'll use an array for month names, but i don't see how that helps selecting months
Quote:
Originally Posted by Old Pedant
This isn't close to right:
Code:
DayOfYear = days - (year*365)
That ignores any leap years that have already occurred!
|
year/4 can give the number of leap years, but I don't know where to add it