1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/date] [DOC] Enhanced RDoc for <=> (https://github.com/ruby/date/pull/65)

0cdbaa92e9
This commit is contained in:
Burdette Lamar 2022-07-28 16:36:54 -05:00 committed by git
parent c56e957dec
commit c348f5a91c

View file

@ -6708,19 +6708,43 @@ cmp_dd(VALUE self, VALUE other)
/* /*
* call-seq: * call-seq:
* d <=> other -> -1, 0, +1 or nil * self <=> other -> -1, 0, 1 or nil
* *
* Compares the two dates and returns -1, zero, 1 or nil. The other * Compares +self+ and +other+, returning:
* should be a date object or a numeric value as an astronomical
* Julian day number.
* *
* Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1 * - <tt>-1</tt> if +other+ is larger.
* Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0 * - <tt>0</tt> if the two are equal.
* Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1 * - <tt>1</tt> if +other+ is smaller.
* Date.new(2001,2,3) <=> Object.new #=> nil * - +nil+ if the two are incomparable.
* Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0 *
* Argument +other+ may be:
*
* - Another \Date object:
*
* d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)>
* prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)>
* next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)>
* d <=> next_date # => -1
* d <=> d # => 0
* d <=> prev_date # => 1
*
* - A DateTime object:
*
* d <=> DateTime.new(2022, 7, 26) # => 1
* d <=> DateTime.new(2022, 7, 27) # => 0
* d <=> DateTime.new(2022, 7, 29) # => -1
*
* - A numeric (compares <tt>self.ajd</tt> to +other+):
*
* d <=> 2459789 # => -1
* d <=> 2459788 # => -1
* d <=> 2459787 # => 1
* d <=> d.ajd # => 0
*
* - Any other object:
*
* d <=> Object.new # => nil
* *
* See also Comparable.
*/ */
static VALUE static VALUE
d_lite_cmp(VALUE self, VALUE other) d_lite_cmp(VALUE self, VALUE other)