@@ -4493,23 +4493,26 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
4493
4493
* call-seq:
4494
4494
* Date._parse(string, comp = true, limit: 128) -> hash
4495
4495
*
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.
4498
4502
*
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+:
4503
4504
*
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}
4507
4506
*
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].
4509
4515
*
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.
4513
4516
*/
4514
4517
static VALUE
4515
4518
date_s__parse (int argc , VALUE * argv , VALUE klass )
@@ -4521,27 +4524,31 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
4521
4524
* call-seq:
4522
4525
* Date.parse(string = '-4712-01-01', comp = true, start = Date::ITALY, limit: 128) -> date
4523
4526
*
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.
4526
4533
*
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+:
4531
4535
*
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>
4535
4539
*
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:
4539
4543
*
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].
4543
4551
*
4544
- * See argument {start}[rdoc-ref:Date@Argument+start].
4545
4552
*/
4546
4553
static VALUE
4547
4554
date_s_parse (int argc , VALUE * argv , VALUE klass )
@@ -4582,11 +4589,14 @@ VALUE date__jisx0301(VALUE);
4582
4589
* call-seq:
4583
4590
* Date._iso8601(string, limit: 128) -> hash
4584
4591
*
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]:
4586
4594
*
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].
4590
4600
*/
4591
4601
static VALUE
4592
4602
date_s__iso8601 (int argc , VALUE * argv , VALUE klass )
@@ -4603,18 +4613,19 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
4603
4613
* call-seq:
4604
4614
* Date.iso8601(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
4605
4615
*
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]:
4608
4619
*
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>
4612
4623
*
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].
4616
4628
*
4617
- * See argument {start}[rdoc-ref:Date@Argument+start].
4618
4629
*/
4619
4630
static VALUE
4620
4631
date_s_iso8601 (int argc , VALUE * argv , VALUE klass )
@@ -4645,11 +4656,15 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
4645
4656
* call-seq:
4646
4657
* Date._rfc3339(string, limit: 128) -> hash
4647
4658
*
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]:
4649
4661
*
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].
4653
4668
*/
4654
4669
static VALUE
4655
4670
date_s__rfc3339 (int argc , VALUE * argv , VALUE klass )
@@ -4666,16 +4681,19 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
4666
4681
* call-seq:
4667
4682
* Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
4668
4683
*
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]:
4671
4687
*
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>
4673
4691
*
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].
4677
4696
*
4678
- * See argument {start}[rdoc-ref:Date@Argument+start].
4679
4697
*/
4680
4698
static VALUE
4681
4699
date_s_rfc3339 (int argc , VALUE * argv , VALUE klass )
@@ -4706,11 +4724,14 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
4706
4724
* call-seq:
4707
4725
* Date._xmlschema(string, limit: 128) -> hash
4708
4726
*
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:
4710
4729
*
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].
4714
4735
*/
4715
4736
static VALUE
4716
4737
date_s__xmlschema (int argc , VALUE * argv , VALUE klass )
@@ -4727,16 +4748,17 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
4727
4748
* call-seq:
4728
4749
* Date.xmlschema(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
4729
4750
*
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:
4732
4753
*
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>
4734
4757
*
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:
4738
4759
*
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].
4740
4762
*
4741
4763
*/
4742
4764
static VALUE
@@ -4768,11 +4790,15 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4768
4790
* call-seq:
4769
4791
* Date._rfc2822(string, limit: 128) -> hash
4770
4792
*
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]:
4772
4795
*
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].
4776
4802
*
4777
4803
* Date._rfc822 is an alias for Date._rfc2822.
4778
4804
*/
@@ -4791,17 +4817,18 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
4791
4817
* call-seq:
4792
4818
* Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
4793
4819
*
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]:
4796
4823
*
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>
4799
4827
*
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:
4803
4829
*
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].
4805
4832
*
4806
4833
* Date.rfc822 is an alias for Date.rfc2822.
4807
4834
*/
@@ -4833,14 +4860,14 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4833
4860
* call-seq:
4834
4861
* Date._httpdate(string, limit: 128) -> hash
4835
4862
*
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:
4837
4865
*
4838
4866
* d = Date.new(2001, 2, 3)
4839
4867
* s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
4840
4868
* Date._httpdate(s)
4841
4869
* # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
4842
4870
*
4843
- * See argument {limit}[rdoc-ref:Date@Argument+limit].
4844
4871
*/
4845
4872
static VALUE
4846
4873
date_s__httpdate (int argc , VALUE * argv , VALUE klass )
@@ -4857,17 +4884,18 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
4857
4884
* call-seq:
4858
4885
* Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
4859
4886
*
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]:
4862
4890
*
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>
4865
4894
*
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:
4869
4896
*
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].
4871
4899
*
4872
4900
*/
4873
4901
static VALUE
@@ -4898,11 +4926,14 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
4898
4926
* call-seq:
4899
4927
* Date._jisx0301(string, limit: 128) -> hash
4900
4928
*
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:
4902
4931
*
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].
4906
4937
*/
4907
4938
static VALUE
4908
4939
date_s__jisx0301 (int argc , VALUE * argv , VALUE klass )
@@ -4919,20 +4950,21 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
4919
4950
* call-seq:
4920
4951
* Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
4921
4952
*
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:
4924
4955
*
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>
4926
4959
*
4927
4960
* For no-era year, legacy format, Heisei is assumed.
4928
4961
*
4929
- * Date.jisx0301('13.02.03') # => #<Date: 2001-02-03 ... >
4962
+ * Date.jisx0301('13.02.03') # => #<Date: 2001-02-03>
4930
4963
*
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:
4934
4965
*
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].
4936
4968
*
4937
4969
*/
4938
4970
static VALUE
0 commit comments