Project

General

Profile

Actions

Feature #4391

closed

date/delta tests

Added by skra (Sebastian Krause) about 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
[ruby-core:35214]

Description

=begin
Attached are a few tests for the Date::Delta class. I hope they are of some use.
And some points which might be considered bugs.
(Everything for 1.9.2 patchlevel 174, probably applies to older versions too)

i) Interplay with the Time class
So the following doesn't look right:
irb(main):005:0> t1 = Time.new(2011)
=> 2011-01-01 00:00:00 +0100
irb(main):006:0> t2 = Date::Delta.days(1)
=> #<Date::Delta: +(1d 00:00'00"000)+(0y 0m) (1/1+0i)>
irb(main):007:0> t1 + t2
=> 2011-01-01 00:00:01 +0100

ii) Difference of Dates is number
This leads to the following strange behavior:
irb(main):016:0> t1 = Date.new(2011,2)
=> #<Date: 2011-02-01 (4911187/2,0,2299161)>
irb(main):017:0> t1 - t1 + Date::Delta.months(1)
=> ((0/1)+(1/1)*i)

Wouldn't it be better, if date arithmetic stayed in the classes Date and Date::Delta when
date/delta is loaded?

iii) multiplication with scalars
I don't know what the coercion principles exactly are. So this might be okay.

irb(main):003:0> 2 * Date::Delta.days(2)
=> ((4/1)+(0/1)*i)
irb(main):004:0> Date::Delta.days(2) * 2
=> #<Date::Delta: +(4d 00:00'00"000)+(0y 0m) (4/1+0i)>

Can I add some documentation? Is there a standard way to do it or should I just go ahead and copy the style from other parts.
=end


Files

test_date_delta.rb (5.67 KB) test_date_delta.rb skra (Sebastian Krause), 02/13/2011 12:43 AM
Actions #1

Updated by naruse (Yui NARUSE) about 13 years ago

  • Status changed from Open to Assigned
  • Assignee set to tadf (tadayoshi funaba)

=begin

=end

Updated by tadf (tadayoshi funaba) about 13 years ago

=begin
i'm planning to remove this undocumented feature.
i once tried to remove this experimental feature.
because, i felt i could not assign my time enough.
in fact, i removed this.
however, it reverted.
because, we were already in period of feature freeze at that time.
i was going to improve the delta.
however, now i'd like to improve date.

thanks.
=end

Updated by tadf (tadayoshi funaba) about 13 years ago

  • Status changed from Assigned to Rejected

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0