@@ -4493,23 +4493,26 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
44934493 * call-seq:
44944494 * Date._parse(string, comp = true, limit: 128) -> hash
44954495 *
4496- * Parses the given representation of date and time, and returns a
4497- * hash of parsed elements.
4496+ * <b>Note</b>:
4497+ * This method recognizes many forms in +string+,
4498+ * but it is not a validator.
4499+ * If +string+ does not specify a valid date,
4500+ * the result is unpredictable;
4501+ * consider using Date._strptime instead.
44984502 *
4499- * This method *does* *not* function as a validator. If the input
4500- * string does not match valid formats strictly, you may get a cryptic
4501- * result. Should consider to use Date._strptime or DateTime._strptime
4502- * instead of this method as possible.
4503+ * Returns a hash of values parsed from +string+:
45034504 *
4504- * If the optional second argument is true and the detected year is in
4505- * the range "00" to "99", considers the year a 2-digit form and makes
4506- * it full.
4505+ * Date._parse('2001-02-03') # => {:year=>2001, :mon=>2, :mday=>3}
45074506 *
4508- * Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
4507+ * If +comp+ is +true+ and the given year is in the range <tt>(0..99)</tt>,
4508+ * the current century is supplied;
4509+ * otherwise, the year is taken as given:
4510+ *
4511+ * Date._parse('01-02-03', true) # => {:year=>2001, :mon=>2, :mday=>3}
4512+ * Date._parse('01-02-03', false) # => {:year=>1, :mon=>2, :mday=>3}
4513+ *
4514+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
45094515 *
4510- * Raise an ArgumentError when the string length is longer than _limit_.
4511- * You can stop this check by passing <code>limit: nil</code>, but note
4512- * that it may take a long time to parse.
45134516 */
45144517static VALUE
45154518date_s__parse (int argc , VALUE * argv , VALUE klass )
@@ -4521,27 +4524,31 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
45214524 * call-seq:
45224525 * Date.parse(string = '-4712-01-01', comp = true, start = Date::ITALY, limit: 128) -> date
45234526 *
4524- * Parses the given representation of date and time, and creates a
4525- * date object.
4527+ * <b>Note</b>:
4528+ * This method recognizes many forms in +string+,
4529+ * but it is not a validator.
4530+ * If +string+ does not specify a valid date,
4531+ * the result is unpredictable;
4532+ * consider using Date._strptime instead.
45264533 *
4527- * This method *does* *not* function as a validator. If the input
4528- * string does not match valid formats strictly, you may get a cryptic
4529- * result. Should consider to use Date.strptime instead of this method
4530- * as possible.
4534+ * Returns a new \Date object with values parsed from +string+:
45314535 *
4532- * If the optional second argument is true and the detected year is in
4533- * the range "00" to "99", considers the year a 2-digit form and makes
4534- * it full.
4536+ * Date.parse('2001-02-03') # => #<Date: 2001-02-03>
4537+ * Date.parse('20010203') # => #<Date: 2001-02-03>
4538+ * Date.parse('3rd Feb 2001') # => #<Date: 2001-02-03>
45354539 *
4536- * Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
4537- * Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
4538- * Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
4540+ * If +comp+ is +true+ and the given year is in the range <tt>(0..99)</tt>,
4541+ * the current century is supplied;
4542+ * otherwise, the year is taken as given:
45394543 *
4540- * Raise an ArgumentError when the string length is longer than _limit_.
4541- * You can stop this check by passing <code>limit: nil</code>, but note
4542- * that it may take a long time to parse.
4544+ * Date.parse('01-02-03', true) # => #<Date: 2001-02-03>
4545+ * Date.parse('01-02-03', false) # => #<Date: 0001-02-03>
4546+ *
4547+ * See:
4548+ *
4549+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4550+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
45434551 *
4544- * See argument {start}[rdoc-ref:Date@Argument+start].
45454552 */
45464553static VALUE
45474554date_s_parse (int argc , VALUE * argv , VALUE klass )
@@ -4582,11 +4589,14 @@ VALUE date__jisx0301(VALUE);
45824589 * call-seq:
45834590 * Date._iso8601(string, limit: 128) -> hash
45844591 *
4585- * Returns a hash of parsed elements.
4592+ * Returns a hash of values parsed from +string+, which should contain
4593+ * an {ISO 8601 formatted date}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]:
45864594 *
4587- * Raise an ArgumentError when the string length is longer than _limit_.
4588- * You can stop this check by passing <code>limit: nil</code>, but note
4589- * that it may take a long time to parse.
4595+ * d = Date.new(2001, 2, 3)
4596+ * s = d.iso8601 # => "2001-02-03"
4597+ * Date._iso8601(s) # => {:mday=>3, :year=>2001, :mon=>2}
4598+ *
4599+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
45904600 */
45914601static VALUE
45924602date_s__iso8601 (int argc , VALUE * argv , VALUE klass )
@@ -4603,18 +4613,19 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
46034613 * call-seq:
46044614 * Date.iso8601(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
46054615 *
4606- * Creates a new Date object by parsing from a string according to
4607- * some typical ISO 8601 formats.
4616+ * Returns a new \Date object with values parsed from +string+,
4617+ * which should contain
4618+ * an {ISO 8601 formatted date}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]:
46084619 *
4609- * Date.iso8601(' 2001-02-03') #=> #<Date: 2001-02-03 ...>
4610- * Date .iso8601('20010203') # => #<Date: 2001-02-03 ...>
4611- * Date.iso8601('2001-W05-6') # => #<Date: 2001-02-03 ... >
4620+ * d = Date.new( 2001, 2, 3)
4621+ * s = d .iso8601 # => " 2001-02-03"
4622+ * Date.iso8601(s) # => #<Date: 2001-02-03>
46124623 *
4613- * Raise an ArgumentError when the string length is longer than _limit_.
4614- * You can stop this check by passing <code>limit: nil</code>, but note
4615- * that it may take a long time to parse.
4624+ * See:
4625+ *
4626+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4627+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
46164628 *
4617- * See argument {start}[rdoc-ref:Date@Argument+start].
46184629 */
46194630static VALUE
46204631date_s_iso8601 (int argc , VALUE * argv , VALUE klass )
@@ -4645,11 +4656,15 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
46454656 * call-seq:
46464657 * Date._rfc3339(string, limit: 128) -> hash
46474658 *
4648- * Returns a hash of parsed elements.
4659+ * Returns a hash of values parsed from +string+, which should be a valid
4660+ * {RFC 3339 format}[https://datatracker.ietf.org/doc/html/rfc3339]:
46494661 *
4650- * Raise an ArgumentError when the string length is longer than _limit_.
4651- * You can stop this check by passing <code>limit: nil</code>, but note
4652- * that it may take a long time to parse.
4662+ * d = Date.new(2001, 2, 3)
4663+ * s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
4664+ * Date._rfc3339(s)
4665+ * # => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0}
4666+ *
4667+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
46534668 */
46544669static VALUE
46554670date_s__rfc3339 (int argc , VALUE * argv , VALUE klass )
@@ -4666,16 +4681,19 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
46664681 * call-seq:
46674682 * Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
46684683 *
4669- * Creates a new Date object by parsing from a string according to
4670- * some typical RFC 3339 formats.
4684+ * Returns a new \Date object with values parsed from +string+,
4685+ * which should be a valid
4686+ * {RFC 3339 format}[https://datatracker.ietf.org/doc/html/rfc3339]:
46714687 *
4672- * Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
4688+ * d = Date.new(2001, 2, 3)
4689+ * s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
4690+ * Date.rfc3339(s) # => #<Date: 2001-02-03>
46734691 *
4674- * Raise an ArgumentError when the string length is longer than _limit_.
4675- * You can stop this check by passing <code>limit: nil</code>, but note
4676- * that it may take a long time to parse.
4692+ * See:
4693+ *
4694+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4695+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
46774696 *
4678- * See argument {start}[rdoc-ref:Date@Argument+start].
46794697 */
46804698static VALUE
46814699date_s_rfc3339 (int argc , VALUE * argv , VALUE klass )
@@ -4706,11 +4724,14 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
47064724 * call-seq:
47074725 * Date._xmlschema(string, limit: 128) -> hash
47084726 *
4709- * Returns a hash of parsed elements.
4727+ * Returns a hash of values parsed from +string+, which should be a valid
4728+ * XML date format:
47104729 *
4711- * Raise an ArgumentError when the string length is longer than _limit_.
4712- * You can stop this check by passing <code>limit: nil</code>, but note
4713- * that it may take a long time to parse.
4730+ * d = Date.new(2001, 2, 3)
4731+ * s = d.xmlschema # => "2001-02-03"
4732+ * Date._xmlschema(s) # => {:year=>2001, :mon=>2, :mday=>3}
4733+ *
4734+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
47144735 */
47154736static VALUE
47164737date_s__xmlschema (int argc , VALUE * argv , VALUE klass )
@@ -4727,16 +4748,17 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
47274748 * call-seq:
47284749 * Date.xmlschema(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
47294750 *
4730- * Creates a new Date object by parsing from a string according to
4731- * some typical XML Schema formats.
4751+ * Returns a new \ Date object with values parsed from + string+,
4752+ * which should be a valid XML date format:
47324753 *
4733- * Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
4754+ * d = Date.new(2001, 2, 3)
4755+ * s = d.xmlschema # => "2001-02-03"
4756+ * Date.xmlschema(s) # => #<Date: 2001-02-03>
47344757 *
4735- * Raise an ArgumentError when the string length is longer than _limit_.
4736- * You can stop this check by passing <code>limit: nil</code>, but note
4737- * that it may take a long time to parse.
4758+ * See:
47384759 *
4739- * See argument {start}[rdoc-ref:Date@Argument+start].
4760+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4761+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
47404762 *
47414763 */
47424764static VALUE
@@ -4768,11 +4790,15 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
47684790 * call-seq:
47694791 * Date._rfc2822(string, limit: 128) -> hash
47704792 *
4771- * Returns a hash of parsed elements.
4793+ * Returns a hash of values parsed from +string+, which should be a valid
4794+ * {RFC 2822 date format}[https://datatracker.ietf.org/doc/html/rfc2822]:
47724795 *
4773- * Raise an ArgumentError when the string length is longer than _limit_.
4774- * You can stop this check by passing <code>limit: nil</code>, but note
4775- * that it may take a long time to parse.
4796+ * d = Date.new(2001, 2, 3)
4797+ * s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
4798+ * Date._rfc2822(s)
4799+ * # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
4800+ *
4801+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
47764802 *
47774803 * Date._rfc822 is an alias for Date._rfc2822.
47784804 */
@@ -4791,17 +4817,18 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
47914817 * call-seq:
47924818 * Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
47934819 *
4794- * Creates a new Date object by parsing from a string according to
4795- * some typical RFC 2822 formats.
4820+ * Returns a new \Date object with values parsed from +string+,
4821+ * which should be a valid
4822+ * {RFC 2822 date format}[https://datatracker.ietf.org/doc/html/rfc2822]:
47964823 *
4797- * Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
4798- * #=> #<Date: 2001-02-03 ...>
4824+ * d = Date.new(2001, 2, 3)
4825+ * s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
4826+ * Date.rfc2822(s) # => #<Date: 2001-02-03>
47994827 *
4800- * Raise an ArgumentError when the string length is longer than _limit_.
4801- * You can stop this check by passing <code>limit: nil</code>, but note
4802- * that it may take a long time to parse.
4828+ * See:
48034829 *
4804- * See argument {start}[rdoc-ref:Date@Argument+start].
4830+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4831+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
48054832 *
48064833 * Date.rfc822 is an alias for Date.rfc2822.
48074834 */
@@ -4833,14 +4860,14 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
48334860 * call-seq:
48344861 * Date._httpdate(string, limit: 128) -> hash
48354862 *
4836- * Returns a hash of values parsed from +string+:
4863+ * Returns a hash of values parsed from +string+, which should be a valid
4864+ * HTTP date format:
48374865 *
48384866 * d = Date.new(2001, 2, 3)
48394867 * s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
48404868 * Date._httpdate(s)
48414869 * # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
48424870 *
4843- * See argument {limit}[rdoc-ref:Date@Argument+limit].
48444871 */
48454872static VALUE
48464873date_s__httpdate (int argc , VALUE * argv , VALUE klass )
@@ -4857,17 +4884,18 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
48574884 * call-seq:
48584885 * Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
48594886 *
4860- * Creates a new Date object by parsing from a string according to
4861- * some RFC 2616 format.
4887+ * Returns a new \Date object with values parsed from +string+,
4888+ * which should be a valid
4889+ * {RFC 2616 date format}[https://datatracker.ietf.org/doc/html/rfc2616]:
48624890 *
4863- * Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
4864- * #=> #<Date: 2001-02-03 ...>
4891+ * d = Date.new(2001, 2, 3)
4892+ s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
4893+ Date.httpdate(s) # => #<Date: 2001-02-03>
48654894 *
4866- * Raise an ArgumentError when the string length is longer than _limit_.
4867- * You can stop this check by passing <code>limit: nil</code>, but note
4868- * that it may take a long time to parse.
4895+ * See:
48694896 *
4870- * See argument {start}[rdoc-ref:Date@Argument+start].
4897+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4898+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
48714899 *
48724900 */
48734901static VALUE
@@ -4898,11 +4926,14 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
48984926 * call-seq:
48994927 * Date._jisx0301(string, limit: 128) -> hash
49004928 *
4901- * Returns a hash of parsed elements.
4929+ * Returns a hash of values parsed from +string+, which should be a valid
4930+ * JIS X 0301 date format:
49024931 *
4903- * Raise an ArgumentError when the string length is longer than _limit_.
4904- * You can stop this check by passing <code>limit: nil</code>, but note
4905- * that it may take a long time to parse.
4932+ * d = Date.new(2001, 2, 3)
4933+ * s = d.jisx0301 # => "H13.02.03"
4934+ * Date._jisx0301(s) # => {:year=>2001, :mon=>2, :mday=>3}
4935+ *
4936+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
49064937 */
49074938static VALUE
49084939date_s__jisx0301 (int argc , VALUE * argv , VALUE klass )
@@ -4919,20 +4950,21 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
49194950 * call-seq:
49204951 * Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
49214952 *
4922- * Creates a new Date object by parsing from a string according to
4923- * some typical JIS X 0301 formats.
4953+ * Returns a new \ Date object with values parsed from + string+,
4954+ * which should be a valid JIS X 0301 format:
49244955 *
4925- * Date.jisx0301('H13.02.03') #=> #<Date: 2001-02-03 ...>
4956+ * d = Date.new(2001, 2, 3)
4957+ * s = d.jisx0301 # => "H13.02.03"
4958+ * Date.jisx0301(s) # => #<Date: 2001-02-03>
49264959 *
49274960 * For no-era year, legacy format, Heisei is assumed.
49284961 *
4929- * Date.jisx0301('13.02.03') # => #<Date: 2001-02-03 ... >
4962+ * Date.jisx0301('13.02.03') # => #<Date: 2001-02-03>
49304963 *
4931- * Raise an ArgumentError when the string length is longer than _limit_.
4932- * You can stop this check by passing <code>limit: nil</code>, but note
4933- * that it may take a long time to parse.
4964+ * See:
49344965 *
4935- * See argument {start}[rdoc-ref:Date@Argument+start].
4966+ * - Argument {start}[rdoc-ref:Date@Argument+start].
4967+ * - Argument {limit}[rdoc-ref:Date@Argument+limit].
49364968 *
49374969 */
49384970static VALUE
0 commit comments