Skip to content

Commit 00326ff

Browse files
Enhanced RDoc (#67)
Treats: ::httpdate #to_date #to_time #to_datetime In behalf of ::httpdate, I've introduced section "Argument limit" that can be pointed to by various Date methods (similar to existing section "Argument start"). This will involve 8 already-enhanced methods plus 8 more not yet done.
1 parent aed66fe commit 00326ff

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

ext/date/date_core.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4833,11 +4833,14 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
48334833
* call-seq:
48344834
* Date._httpdate(string, limit: 128) -> hash
48354835
*
4836-
* Returns a hash of parsed elements.
4836+
* Returns a hash of values parsed from +string+:
48374837
*
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].
48414844
*/
48424845
static VALUE
48434846
date_s__httpdate(int argc, VALUE *argv, VALUE klass)
@@ -8760,10 +8763,15 @@ time_to_datetime(VALUE self)
87608763

87618764
/*
87628765
* 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
87648774
*
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.
87678775
*/
87688776
static VALUE
87698777
date_to_time(VALUE self)
@@ -8784,9 +8792,9 @@ date_to_time(VALUE self)
87848792

87858793
/*
87868794
* call-seq:
8787-
* d.to_date -> self
8795+
* to_date -> self
87888796
*
8789-
* Returns self.
8797+
* Returns +self+.
87908798
*/
87918799
static VALUE
87928800
date_to_date(VALUE self)
@@ -8798,7 +8806,10 @@ date_to_date(VALUE self)
87988806
* call-seq:
87998807
* d.to_datetime -> datetime
88008808
*
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+
*
88028813
*/
88038814
static VALUE
88048815
date_to_datetime(VALUE self)
@@ -9498,6 +9509,19 @@ Init_date_core(void)
94989509
* - Date::JULIAN - no changeover date; all dates are Julian.
94999510
* - Date::GREGORIAN - no changeover date; all dates are Gregorian.
95009511
*
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+
*
95019525
*/
95029526
cDate = rb_define_class("Date", rb_cObject);
95039527

0 commit comments

Comments
 (0)