From 6d43cf9ac1e9f5e2670e86f243594b92443ccc5b Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Wed, 27 Jul 2022 13:57:11 -0500 Subject: [PATCH 1/5] Enhanced RDoc for <=> --- 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 a1dc938..c224358 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.today # => # + * 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, 28) # => -1 + * d <=> DateTime.new(2022, 7, 27) # => 0 + * d <=> DateTime.new(2022, 7, 29) # => -1 + * + * - A numeric (compares self.jd to +other+): + * + * d <=> 2459789 # => -1 + * d <=> 2459788 # => -1 + * d <=> 2459787 # => 1 + * + * - Any other object: + * + * d <=> Object.new # => nil * - * See also Comparable. */ static VALUE d_lite_cmp(VALUE self, VALUE other) From 93012fab460e2f15d74844e1d1231cf0a922a071 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 28 Jul 2022 09:30:08 -0500 Subject: [PATCH 2/5] Enhanced RDoc of <=> --- ext/date/date_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index c224358..282af01 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6735,7 +6735,7 @@ cmp_dd(VALUE self, VALUE other) * d <=> DateTime.new(2022, 7, 27) # => 0 * d <=> DateTime.new(2022, 7, 29) # => -1 * - * - A numeric (compares self.jd to +other+): + * - A numeric (compares self.ajd to +other+): * * d <=> 2459789 # => -1 * d <=> 2459788 # => -1 From 64851ee4db0a1951931e9d7c022474343eb73f84 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 28 Jul 2022 10:22:46 -0500 Subject: [PATCH 3/5] Enhanced RDoc for <=> --- ext/date/date_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 282af01..410622a 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6721,13 +6721,13 @@ cmp_dd(VALUE self, VALUE other) * * - Another \Date object: * - * d = Date.today # => # - * prev_date = d.prev_day # => # - * next_date = d.next_day # => # - * d <=> next_date # => -1 - * d <=> d # => 0 - * d <=> prev_date # => 1 - * + * 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 + * d <=> d.ajd # => 0 * * - A DateTime object: * From 2b6d1b049f839f61cbe90fd4f720ddcf1a6d6222 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 28 Jul 2022 11:03:50 -0500 Subject: [PATCH 4/5] Enhanced RDoc for <=> --- ext/date/date_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 410622a..68609ea 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6727,7 +6727,6 @@ cmp_dd(VALUE self, VALUE other) * d <=> next_date # => -1 * d <=> d # => 0 * d <=> prev_date # => 1 - * d <=> d.ajd # => 0 * * - A DateTime object: * @@ -6740,6 +6739,7 @@ cmp_dd(VALUE self, VALUE other) * d <=> 2459789 # => -1 * d <=> 2459788 # => -1 * d <=> 2459787 # => 1 + * d <=> d.ajd # => 0 * * - Any other object: * From ab2209383d1e548b7526160ec7da10047a4e08ad Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Thu, 28 Jul 2022 13:14:49 -0500 Subject: [PATCH 5/5] Update ext/date/date_core.c Co-authored-by: Peter Zhu --- ext/date/date_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 68609ea..9214333 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6730,7 +6730,7 @@ cmp_dd(VALUE self, VALUE other) * * - A DateTime object: * - * d <=> DateTime.new(2022, 7, 28) # => -1 + * d <=> DateTime.new(2022, 7, 26) # => 1 * d <=> DateTime.new(2022, 7, 27) # => 0 * d <=> DateTime.new(2022, 7, 29) # => -1 *