Project

General

Profile

Actions

Bug #2675

closed

rubyspec: Date#valid_civil? should be able to handle negative months and days FAILED

Added by mame (Yusuke Endoh) over 15 years ago. Updated over 14 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2010-01-28 trunk 26458) [i686-linux]
Backport:
[ruby-dev:40208]

Description

=begin
ふなばさん
遠藤です。

まず確認ですが、valid_civil? が jd or nil を返すという仕様から
true or false を返すようになったのは 1.9 から (というか Date2
から?) の仕様変更ですよね。

その点を修正した上で、rubyspec が以下の挙動の変化を検出しました。

$ ruby18 -v -rdate -e 'p Date.valid_civil?(1582, -3, -18)'
ruby 1.8.8dev (2010-01-26 revision 26430) [i686-linux]
nil

$ ./ruby -v -rdate -e 'p Date.valid_civil?(1582, -3, -18)'
ruby 1.9.2dev (2010-01-28 trunk 26458) [i686-linux]
true

$ ruby-1.9.1-p378 -v -rdate -e 'p Date.valid_civil?(1582, -3, -18)'
ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux]
true

「Date の月日に負の値を入れても動く」という spec があって、
それがうまく動かなくなっているようです。

http://github.com/rubyspec/rubyspec/blob/master/library/date/civil_spec.rb

date.rb の _valid_civil? のコメントによると、負の値でも動く
ようなことが書かれていますので、これはバグでしょうか。

 # +m+ and +d+ can be negative, in which case they count
 # backwards from the end of the year and the end of the
 # month respectively.

--
Yusuke ENDOH
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0