[ruby-talk:00163] Re: Happy new year!

From: gotoken@... (GOTO Kentaro)
Date: 1999-01-01 17:38:51 UTC
List: ruby-talk #163
=begin
In message "[ruby-talk:00162] Re: Happy new year!"
    on 99/01/01, Yukihiro Matsumoto <matz@netlab.co.jp> writes:

>p.s.
>Is this a last year of the century or not?
=end

class UndecidableError<Exception; end

class Time
  def century
    y = year
    unless y % 100 == 0
      1 + y/100
    else
      # You can find lot of dispute over this problem in
      # ``Questioning the millennium'' by Stephen Jay Gould 
      # (Harmony Books, 1997). 

      raise UndecidableError.new(
        "decide #{y/100}th or #{1+y/100}st for `#{inspect}' at your own risk")
    end
  end
end

#-- gotoken

In This Thread

Prev Next