[前][次][番号順一覧][スレッド一覧]

ruby-changes:72749

From: Burdette <ko1@a...>
Date: Sat, 30 Jul 2022 04:51:24 +0900 (JST)
Subject: [ruby-changes:72749] 53175643ef (master): [ruby/date] [DOC] Enhanced RDoc (https://github.com/ruby/date/pull/66)

https://git.ruby-lang.org/ruby.git/commit/?id=53175643ef

From 53175643ef826775d0a51fc48fdd79a4cf01dc70 Mon Sep 17 00:00:00 2001
From: Burdette Lamar <BurdetteLamar@Y...>
Date: Fri, 29 Jul 2022 14:50:56 -0500
Subject: [ruby/date] [DOC] Enhanced RDoc
 (https://github.com/ruby/date/pull/66)

Treats:
    #===
    #to_s
    #inspect
    #strftme
    #asctime
    #iso3601
    #rfc3339
    #rfc2822
    #httpdate
    #jisx0301

https://github.com/ruby/date/commit/aed66fedf6
---
 ext/date/date_core.c | 144 +++++++++++++++++++++++++++++++++------------------
 1 file changed, 93 insertions(+), 51 deletions(-)

diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 9214333eed..d8048194ce 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -6344,9 +6344,9 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6344
  *
  * Returns a new \Date object representing the following day:
  *
- *   d = Date.today
- *   d.to_s      # => "2022-07-11"
- *   d.next.to_s # => "2022-07-12"
+ *   d = Date.new(2001, 2, 3)
+ *   d.to_s      # => "2001-02-03"
+ *   d.next.to_s # => "2001-02-04"
  *
  * Date#succ is an alias for Date#next.
  */
@@ -6732,13 +6732,13 @@ cmp_dd(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6732
  *
  *     d <=> DateTime.new(2022, 7, 26) # => 1
  *     d <=> DateTime.new(2022, 7, 27) # => 0
- *     d <=> DateTime.new(2022, 7, 29) # => -1
+ *     d <=> DateTime.new(2022, 7, 28) # => -1
  *
  * - A numeric (compares <tt>self.ajd</tt> to +other+):
  *
- *     d <=> 2459789 # => -1
  *     d <=> 2459788 # => -1
  *     d <=> 2459787 # => 1
+ *     d <=> 2459786 # => 1
  *     d <=> d.ajd   # => 0
  *
  * - Any other object:
@@ -6804,20 +6804,39 @@ equal_gen(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6804
 
 /*
  * call-seq:
- *    d === other  ->  bool
- *
- * Returns true if they are the same day.
- *
- *    Date.new(2001,2,3) === Date.new(2001,2,3)
- * 					#=> true
- *    Date.new(2001,2,3) === Date.new(2001,2,4)
- *					#=> false
- *    DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12)
- *					#=> true
- *    DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00')
- *					#=> true
- *    DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00')
- *					#=> false
+ *   self === other -> true, false, or nil.
+ *
+ * Returns +true+ if +self+ and +other+ represent the same date,
+ * +false+ if not, +nil+ if the two are not comparable.
+ *
+ * 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 === prev_date           # => false
+ *     d === d                   # => true
+ *     d === next_date           # => false
+ *
+ * - A DateTime object:
+ *
+ *     d === DateTime.new(2022, 7, 26) # => false
+ *     d === DateTime.new(2022, 7, 27) # => true
+ *     d === DateTime.new(2022, 7, 28) # => false
+ *
+ * - A numeric (compares <tt>self.jd</tt> to +other+):
+ *
+ *     d === 2459788 # => true
+ *     d === 2459787 # => false
+ *     d === 2459786 # => false
+ *     d === d.jd    # => true
+ *
+ * - An object not comparable:
+ *
+ *     d === Object.new # => nil
+ *
  */
 static VALUE
 d_lite_equal(VALUE self, VALUE other)
@@ -6880,12 +6899,14 @@ static VALUE strftimev(const char *, VALUE, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6899
 
 /*
  * call-seq:
- *    d.to_s  ->  string
+ *   to_s -> string
  *
- * Returns a string in an ISO 8601 format. (This method doesn't use the
- * expanded representations.)
+ * Returns a string representation of the date in +self+
+ * in {ISO 8601 extended date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]
+ * (<tt>'%Y-%m-%d'</tt>):
+ *
+ *   Date.new(2001, 2, 3).to_s # => "2001-02-03"
  *
- *     Date.new(2001,2,3).to_s	#=> "2001-02-03"
  */
 static VALUE
 d_lite_to_s(VALUE self)
@@ -6966,14 +6987,13 @@ mk_inspect(union DateData *x, VALUE klass, VALUE to_s) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6987
 
 /*
  * call-seq:
- *    d.inspect  ->  string
+ *   inspect -> string
+ *
+ * Returns a string representation of +self+:
  *
- * Returns the value as a string for inspection.
+ *   Date.new(2001, 2, 3).inspect
+ *   # => "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
  *
- *    Date.new(2001,2,3).inspect
- *		#=> "#<Date: 2001-02-03>"
- *    DateTime.new(2001,2,3,4,5,6,'-7').inspect
- *		#=> "#<DateTime: 2001-02-03T04:05:06-07:00>"
  */
 static VALUE
 d_lite_inspect(VALUE self)
@@ -7155,12 +7175,12 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7175
 
 /*
  * call-seq:
- *    strftime(format = '%F') -> string
+ *   strftime(format = '%F') -> string
  *
- * Returns a string representation of +self+,
+ * Returns a string representation of the date in +self+,
  * formatted according the given +format+:
  *
- *   Date.today.strftime # => "2022-07-01"
+ *   Date.new(2001, 2, 3).strftime # => "2001-02-03"
  *
  * For other formats, see
  * {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html].
@@ -7192,13 +7212,17 @@ strftimev(const char *fmt, VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7212
 
 /*
  * call-seq:
- *    d.asctime  ->  string
- *    d.ctime    ->  string
+ *   asctime -> string
+ *
+ * Equivalent to #strftime with argument <tt>'%a %b %e %T %Y'</tt>
+ * (or its {shorthand form}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Shorthand+Conversion+Specifiers]
+ * <tt>'%c'</tt>):
  *
- * Returns a string in asctime(3) format (but without "\n\0" at the
- * end).  This method is equivalent to strftime('%c').
+ *   Date.new(2001, 2, 3).asctime # => "Sat Feb  3 00:00:00 2001"
  *
- * See also asctime(3) or ctime(3).
+ * See {asctime}[https://linux.die.net/man/3/asctime].
+ *
+ * Date#ctime is an alias for Date#asctime.
  */
 static VALUE
 d_lite_asctime(VALUE self)
@@ -7208,10 +7232,15 @@ d_lite_asctime(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7232
 
 /*
  * call-seq:
- *    d.iso8601    ->  string
- *    d.xmlschema  ->  string
+ *   iso8601    ->  string
+ *
+ * Equivalent to #strftime with argument <tt>'%Y-%m-%d'</tt>
+ * (or its {shorthand form}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Shorthand+Conversion+Specifiers]
+ * <tt>'%F'</tt>);
  *
- * This method is equivalent to strftime('%F').
+ *   Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
+ *
+ * Date#xmlschema is an alias for Date#iso8601.
  */
 static VALUE
 d_lite_iso8601(VALUE self)
@@ -7221,9 +7250,13 @@ d_lite_iso8601(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7250
 
 /*
  * call-seq:
- *    d.rfc3339  ->  string
+ *   rfc3339 -> string
+ *
+ * Equivalent to #strftime with argument <tt>'%FT%T%:z'</tt>;
+ * see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
+ *
+ *   Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00"
  *
- * This method is equivalent to strftime('%FT%T%:z').
  */
 static VALUE
 d_lite_rfc3339(VALUE self)
@@ -7233,10 +7266,14 @@ d_lite_rfc3339(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7266
 
 /*
  * call-seq:
- *    d.rfc2822  ->  string
- *    d.rfc822   ->  string
+ *   rfc2822 -> string
+ *
+ * Equivalent to #strftime with argument <tt>'%a, %-d %b %Y %T %z'</tt>;
+ * see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
+ *
+ *   Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
  *
- * This method is equivalent to strftime('%a, %-d %b %Y %T %z').
+ * Date#rfc822 is an alias for Date#rfc2822.
  */
 static VALUE
 d_lite_rfc2822(VALUE self)
@@ -7246,10 +7283,13 @@ d_lite_rfc2822(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7283
 
 /*
  * call-seq:
- *    d.httpdate  ->  string
+ *   httpdate -> string
+ *
+ * Equivalent to #strftime with argument <tt>'%a, %d %b %Y %T GMT'</tt>;
+ * see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
+ *
+ *   Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
  *
- * This method is equivalent to strftime('%a, %d %b %Y %T GMT').
- * See also RFC 2616.
  */
 static VALUE
 d_lite_httpdate(VALUE self)
@@ -7300,11 +7340,13 @@ jisx0301_date_format(char *fmt, size_t size, VALUE jd, VALUE y) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L7340
 
 /*
  * call-seq:
- *    d.jisx0301  ->  string
+ *   jisx0301 -> string
  *
- * Returns a string in a JIS X 0301 format.
+ * Returns a string representation of the date in +self+
+ * in JIS X 0301 format.
+ *
+ *   Date.new(2001, 2, 3).jisx0301 # => "H13.02.03"
  *
- *    Date.new(2001,2,3).jisx0301	#=> "H13.02.03"
  */
 static VALUE
 d_lite_jisx0301(VALUE self)
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]