From c348f5a91c6c5b4a90082d1e64312b4fb0dc7abc Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Thu, 28 Jul 2022 16:36:54 -0500 Subject: [PATCH] [ruby/date] [DOC] Enhanced RDoc for <=> (https://github.com/ruby/date/pull/65) https://github.com/ruby/date/commit/0cdbaa92e9 --- ext/date/date_core.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index a1dc9387e0..9214333eed 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6708,19 +6708,43 @@ cmp_dd(VALUE self, VALUE other) /* * 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 - * should be a date object or a numeric value as an astronomical - * Julian day number. + * Compares +self+ and +other+, returning: * - * Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1 - * Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0 - * Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1 - * Date.new(2001,2,3) <=> Object.new #=> nil - * Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0 + * - -1 if +other+ is larger. + * - 0 if the two are equal. + * - 1 if +other+ is smaller. + * - +nil+ if the two are incomparable. + * + * Argument +other+ may be: + * + * - Another \Date object: + * + * d = Date.new(2022, 7, 27) # => # + * prev_date = d.prev_day # => # + * next_date = d.next_day # => # + * 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 self.ajd 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 d_lite_cmp(VALUE self, VALUE other)