Project

General

Profile

Actions

Bug #8679

closed

Time.newのutc_offset文字列で、 MMが60-99の場合にも例外を出して欲しい

Added by kachick (Kenichi Kamiya) over 11 years ago. Updated about 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0p247 (2013-06-27 revision 41674) [i686-linux]
Backport:
[ruby-dev:47539]

Description

要望

Time.new へ utc_offset を表す文字列 "+HH:MM" "-HH:MM" が渡された時、
MM が 60-99 の場合にも ArgumentError を出して欲しい。

期待する結果の例

Time.new(2000, 1, 1, 0, 0, 0, "+01:60") #=> "+HH:MM" or "-HH:MM" expected for utc_offset (ArgumentError)
Time.new(2000, 1, 1, 0, 0, 0, "+01:99") #=> "+HH:MM" or "-HH:MM" expected for utc_offset (ArgumentError)

現状

ArgumentError を出す例

Time.new(2000, 1, 1, 0, 0, 0, "+23:60") #=> utc_offset out of range (ArgumentError)
Time.new(2000, 1, 1, 0, 0, 0, "+01:100") #=> "+HH:MM" or "-HH:MM" expected for utc_offset (ArgumentError)

ArgumentError を出さない例

Time.new(2000, 1, 1, 0, 0, 0, "+01:60") #=> 2000-01-01 00:00:00 +0200
Time.new(2000, 1, 1, 0, 0, 0, "+01:99") #=> 2000-01-01 00:00:00 +0239

付記

  • 次の RubySpec が通らない事により気づいたのですが、
    これに関しては RubySpec 側で記載された動作になってくれた方が嬉しいと思いました。

    RubySpec

  • example-patch

ruby -v

  • ruby 2.1.0dev (2013-07-23 trunk 42140) [i686-linux]

  • ruby 2.0.0p247 (2013-06-27 revision 41674) [i686-linux]

  • ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]

  • ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]

  • ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]


Files

draft.utc_offset_arg.patch (900 Bytes) draft.utc_offset_arg.patch example-utc_offset_arg.patch kachick (Kenichi Kamiya), 07/24/2013 06:05 PM

Updated by hsbt (Hiroshi SHIBATA) over 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to akr (Akira Tanaka)
Actions #2

Updated by Anonymous about 10 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r47676.


  • time.c: raise exception when minutes of utc_offset is out of 00-59.
    patch is from Kenichi Kamiya.
    [ruby-dev:47539] [Bug #8679]

  • test/ruby/test_time.rb: test for above.
    patch is from Kenichi Kamiya.

Actions

Also available in: Atom PDF

Like0
Like0Like0