All pastes #879908 Raw Edit

Unnamed

public text v1 · immutable
#879908 ·published 2008-01-29 18:36 UTC
rendered paste body
<robp__> Who wants a programming challenge!
<BeB00> O.o
* BeB00 isn't good at RB
<BeB00> lol
<robp__> jdiwnab theredcow
<robp__> okay here's my dilemma
<robp__> I need a way to take a number that is a countdown of the days from January 1st, 2000
<robp__> and return what year that day is in
<robp__> and what day of the year it is
<robp__> i.e.
<robp__> "1" would be Day 1 of year 2000
<robp__> "366" would be Day 1 of year 2001
<robp__> "365" would be Day 365 of year 2000
<robp__> however, it's not as easy as it sounds
<robp__> because one also has to account for leap years
<BeB00> not sure how possible that will be concidering this year is a leap yaer
<BeB00> lol
<BeB00> hmm
<BeB00> i don't even know how often leap years are
<BeB00> lol
<BeB00> is that date static... like is it always Jan 1, 2000?
<robp__> yep
<robp__> If there were no such thing as leap years, you could use modulus
<robp__> but damn you, leap years!
<BeB00> the current standard calendar in most of the world, adds a 29th day to February in 97 years out of every 400, a closer approximation than once every four years.
<BeB00> so...
<BeB00> was 2004 a leap year?
<robp__> pseudocode to determine if a year is a leap year:
<robp__> if year modulo 400 is 0 then leap
<robp__>  else if year modulo 100 is 0 then no_leap
<robp__>  else if year modulo 4 is 0 then leap
<robp__>  else no_leap