Thursday, June 23, 2011

Calculate the firefox year

A rapid pace of growth of IT is often likened to a "dog year". And now, more rapid pace comes! It calls "firefox year".

http://mozilla.jp/firefox/preview/faq/#q-rapid-3
  • Firefox 5 was released at 2011-06-21.
  • Firefox 6 will be released at 8 weeks after Firefox 5's one.
  • Firefox n + 1 will be released at 6 weeks after Firefox n's one.

So I try to calculate the year when the version equals release year and when the version passes release year, in Ruby 1.9.

In Ruby 1.9


# -*- coding: utf-8 -*-
require 'fiber'
require 'date'

next_firefox = Fiber.new do
  ff5 = Date.new(2011, 6, 21)
  ff_next = 6
  ff_next_date = ff5 + 7 * 8
  loop do
    Fiber.yield ff_next, ff_next_date
    ff_next += 1
    ff_next_date += 7 * 6
  end
end

next_firefox_version, next_firefox_date = next_firefox.resume
while (next_firefox_version < next_firefox_date.year) do
  next_firefox_version, next_firefox_date = next_firefox.resume
end
puts "The version equals release year", next_firefox_version, next_firefox_date
next_firefox_version, next_firefox_date = next_firefox.resume
puts "The version passes release year", next_firefox_version, next_firefox_date
The version equals release year
2272
2272-03-12
The version passes release year
2273
2272-04-23
  • When 2272-03-12, firefox version equals release year.
  • When 2272-04-23, firefox version passes release year.

No comments:

Post a Comment