Advertisement
saasbook

date_calculator_bad.rb

Jan 10th, 2012
754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. class TimeSetter
  2.  
  3.   def convert(d)
  4.     y = 1980
  5.     while (d > 365) do
  6.       if (y % 400 == 0 ||
  7.           (y % 4 == 0 && y % 100 == 0))
  8.         if (d > 366)
  9.           d -= 366
  10.           y += 1
  11.         end
  12.       else
  13.         d -= 365
  14.         y += 1
  15.       end
  16.     end
  17.     return y
  18.   end
  19.  
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement