Saturday, September 29, 2012

Calculate the firefox year (Fixed)

(Check also phosphorescence: Calculate the firefox year)

Firefox team announced changing their "Rapid release" plan.

The reason is "the Happy Holidays". BTW, I fix previous "Calculate the firefox year" ruby code for this change.
$ irb -rfiber -rdate
irb(main):001:0> next_firefox = Fiber.new do
irb(main):002:1*   ff5 = Date.new(2011, 6, 21)
irb(main):003:1>   ff_next = 6
irb(main):004:1>   ff_next_date = ff5 + 7 * 8
irb(main):005:1>   loop do
irb(main):006:2*     Fiber.yield ff_next, ff_next_date
irb(main):007:2>     ff_next += 1
irb(main):008:2>     ff_plan_date = ff_next_date + 7 * 6
irb(main):009:2>     ff_happy_holiday = Date.new(ff_next_date.year, 12, 25)
irb(main):010:2>     if ff_happy_holiday.year >= 2012 && (ff_next_date..ff_plan_date).include?(ff_happy_holiday)
irb(main):011:3>       ff_next_date = ff_plan_date + 7
irb(main):012:3>     else
irb(main):013:3*       ff_next_date = ff_plan_date
irb(main):014:3>     end
irb(main):015:2>   end
irb(main):016:1> end
=> #<Fiber:0x2dc0af8>
irb(main):017:0> next_firefox_version, next_firefox_date = next_firefox.resume
=> [6, #<Date: 2011-08-16 ((2455790j,0s,0n),+0s,2299161j)>]
irb(main):018:0> while (next_firefox_version < next_firefox_date.year) do
irb(main):019:1>   next_firefox_version, next_firefox_date = next_firefox.resume
irb(main):020:1> end
=> nil
irb(main):021:0> puts "The version equals release year", next_firefox_version, next_firefox_date
The version equals release year
2277
2277-11-06
=> nil

No comments:

Post a Comment