@@ -4833,11 +4833,14 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4833
4833
* call-seq:
4834
4834
* Date._httpdate(string, limit: 128) -> hash
4835
4835
*
4836
- * Returns a hash of parsed elements.
4836
+ * Returns a hash of values parsed from +string+:
4837
4837
*
4838
- * Raise an ArgumentError when the string length is longer than _limit_.
4839
- * You can stop this check by passing <code>limit: nil</code>, but note
4840
- * that it may take a long time to parse.
4838
+ * d = Date.new(2001, 2, 3)
4839
+ * s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
4840
+ * Date._httpdate(s)
4841
+ * # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
4842
+ *
4843
+ * See argument {limit}[rdoc-ref:Date@Argument+limit].
4841
4844
*/
4842
4845
static VALUE
4843
4846
date_s__httpdate (int argc , VALUE * argv , VALUE klass )
@@ -8760,10 +8763,15 @@ time_to_datetime(VALUE self)
8760
8763
8761
8764
/*
8762
8765
* call-seq:
8763
- * d.to_time -> time
8766
+ * to_time -> time
8767
+ *
8768
+ * Returns a new Time object with the same value as +self+;
8769
+ * if +self+ is a Julian date, derives its Gregorian date
8770
+ * for conversion to the \Time object:
8771
+ *
8772
+ * Date.new(2001, 2, 3).to_time # => 2001-02-03 00:00:00 -0600
8773
+ * Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600
8764
8774
*
8765
- * Returns a Time object which denotes self. If self is a julian date,
8766
- * convert it to a gregorian date before converting it to Time.
8767
8775
*/
8768
8776
static VALUE
8769
8777
date_to_time (VALUE self )
@@ -8784,9 +8792,9 @@ date_to_time(VALUE self)
8784
8792
8785
8793
/*
8786
8794
* call-seq:
8787
- * d. to_date -> self
8795
+ * to_date -> self
8788
8796
*
8789
- * Returns self.
8797
+ * Returns + self+ .
8790
8798
*/
8791
8799
static VALUE
8792
8800
date_to_date (VALUE self )
@@ -8798,7 +8806,10 @@ date_to_date(VALUE self)
8798
8806
* call-seq:
8799
8807
* d.to_datetime -> datetime
8800
8808
*
8801
- * Returns a DateTime object which denotes self.
8809
+ * Returns a DateTime whose value is the same as +self+:
8810
+ *
8811
+ * Date.new(2001, 2, 3).to_datetime # => #<DateTime: 2001-02-03T00:00:00+00:00>
8812
+ *
8802
8813
*/
8803
8814
static VALUE
8804
8815
date_to_datetime (VALUE self )
@@ -9498,6 +9509,19 @@ Init_date_core(void)
9498
9509
* - Date::JULIAN - no changeover date; all dates are Julian.
9499
9510
* - Date::GREGORIAN - no changeover date; all dates are Gregorian.
9500
9511
*
9512
+ * === Argument +limit+
9513
+ *
9514
+ * Certain singleton methods in \Date that parse string arguments
9515
+ * also take optional keyword argument +limit+,
9516
+ * which can limit the length of the string argument.
9517
+ *
9518
+ * When +limit+ is:
9519
+ *
9520
+ * - Non-negative:
9521
+ * raises ArgumentError if the string length is greater than _limit_.
9522
+ * - Other numeric or +nil+: ignores +limit+.
9523
+ * - Other non-numeric: raises TypeError.
9524
+ *
9501
9525
*/
9502
9526
cDate = rb_define_class ("Date" , rb_cObject );
9503
9527
0 commit comments