View Single Post
Old 11-16-2012, 03:13 AM   PM User | #10
Durakken
New to the CF scene

 
Join Date: Nov 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Durakken is an unknown quantity at this point
Quote:
Originally Posted by Old Pedant View Post
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 View Post
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
Durakken is offline   Reply With Quote