Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aed66fe

Browse files
[DOC] Enhanced RDoc (#66)
Treats: #=== #to_s #inspect #strftme #asctime #iso3601 #rfc3339 #rfc2822 #httpdate #jisx0301
1 parent 0cdbaa9 commit aed66fe

File tree

1 file changed

+93
-51
lines changed

1 file changed

+93
-51
lines changed

ext/date/date_core.c

Lines changed: 93 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6344,9 +6344,9 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
63446344
*
63456345
* Returns a new \Date object representing the following day:
63466346
*
6347-
* d = Date.today
6348-
* d.to_s # => "2022-07-11"
6349-
* d.next.to_s # => "2022-07-12"
6347+
* d = Date.new(2001, 2, 3)
6348+
* d.to_s # => "2001-02-03"
6349+
* d.next.to_s # => "2001-02-04"
63506350
*
63516351
* Date#succ is an alias for Date#next.
63526352
*/
@@ -6732,13 +6732,13 @@ cmp_dd(VALUE self, VALUE other)
67326732
*
67336733
* d <=> DateTime.new(2022, 7, 26) # => 1
67346734
* d <=> DateTime.new(2022, 7, 27) # => 0
6735-
* d <=> DateTime.new(2022, 7, 29) # => -1
6735+
* d <=> DateTime.new(2022, 7, 28) # => -1
67366736
*
67376737
* - A numeric (compares <tt>self.ajd</tt> to +other+):
67386738
*
6739-
* d <=> 2459789 # => -1
67406739
* d <=> 2459788 # => -1
67416740
* d <=> 2459787 # => 1
6741+
* d <=> 2459786 # => 1
67426742
* d <=> d.ajd # => 0
67436743
*
67446744
* - Any other object:
@@ -6804,20 +6804,39 @@ equal_gen(VALUE self, VALUE other)
68046804

68056805
/*
68066806
* call-seq:
6807-
* d === other -> bool
6808-
*
6809-
* Returns true if they are the same day.
6810-
*
6811-
* Date.new(2001,2,3) === Date.new(2001,2,3)
6812-
* #=> true
6813-
* Date.new(2001,2,3) === Date.new(2001,2,4)
6814-
* #=> false
6815-
* DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12)
6816-
* #=> true
6817-
* DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00')
6818-
* #=> true
6819-
* DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00')
6820-
* #=> false
6807+
* self === other -> true, false, or nil.
6808+
*
6809+
* Returns +true+ if +self+ and +other+ represent the same date,
6810+
* +false+ if not, +nil+ if the two are not comparable.
6811+
*
6812+
* Argument +other+ may be:
6813+
*
6814+
* - Another \Date object:
6815+
*
6816+
* d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)>
6817+
* prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)>
6818+
* next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)>
6819+
* d === prev_date # => false
6820+
* d === d # => true
6821+
* d === next_date # => false
6822+
*
6823+
* - A DateTime object:
6824+
*
6825+
* d === DateTime.new(2022, 7, 26) # => false
6826+
* d === DateTime.new(2022, 7, 27) # => true
6827+
* d === DateTime.new(2022, 7, 28) # => false
6828+
*
6829+
* - A numeric (compares <tt>self.jd</tt> to +other+):
6830+
*
6831+
* d === 2459788 # => true
6832+
* d === 2459787 # => false
6833+
* d === 2459786 # => false
6834+
* d === d.jd # => true
6835+
*
6836+
* - An object not comparable:
6837+
*
6838+
* d === Object.new # => nil
6839+
*
68216840
*/
68226841
static VALUE
68236842
d_lite_equal(VALUE self, VALUE other)
@@ -6880,12 +6899,14 @@ static VALUE strftimev(const char *, VALUE,
68806899

68816900
/*
68826901
* call-seq:
6883-
* d.to_s -> string
6902+
* to_s -> string
68846903
*
6885-
* Returns a string in an ISO 8601 format. (This method doesn't use the
6886-
* expanded representations.)
6904+
* Returns a string representation of the date in +self+
6905+
* in {ISO 8601 extended date format}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-ISO+8601+Format+Specifications]
6906+
* (<tt>'%Y-%m-%d'</tt>):
6907+
*
6908+
* Date.new(2001, 2, 3).to_s # => "2001-02-03"
68876909
*
6888-
* Date.new(2001,2,3).to_s #=> "2001-02-03"
68896910
*/
68906911
static VALUE
68916912
d_lite_to_s(VALUE self)
@@ -6966,14 +6987,13 @@ mk_inspect(union DateData *x, VALUE klass, VALUE to_s)
69666987

69676988
/*
69686989
* call-seq:
6969-
* d.inspect -> string
6990+
* inspect -> string
6991+
*
6992+
* Returns a string representation of +self+:
69706993
*
6971-
* Returns the value as a string for inspection.
6994+
* Date.new(2001, 2, 3).inspect
6995+
* # => "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
69726996
*
6973-
* Date.new(2001,2,3).inspect
6974-
* #=> "#<Date: 2001-02-03>"
6975-
* DateTime.new(2001,2,3,4,5,6,'-7').inspect
6976-
* #=> "#<DateTime: 2001-02-03T04:05:06-07:00>"
69776997
*/
69786998
static VALUE
69796999
d_lite_inspect(VALUE self)
@@ -7155,12 +7175,12 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
71557175

71567176
/*
71577177
* call-seq:
7158-
* strftime(format = '%F') -> string
7178+
* strftime(format = '%F') -> string
71597179
*
7160-
* Returns a string representation of +self+,
7180+
* Returns a string representation of the date in +self+,
71617181
* formatted according the given +format+:
71627182
*
7163-
* Date.today.strftime # => "2022-07-01"
7183+
* Date.new(2001, 2, 3).strftime # => "2001-02-03"
71647184
*
71657185
* For other formats, see
71667186
* {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,
71927212

71937213
/*
71947214
* call-seq:
7195-
* d.asctime -> string
7196-
* d.ctime -> string
7215+
* asctime -> string
7216+
*
7217+
* Equivalent to #strftime with argument <tt>'%a %b %e %T %Y'</tt>
7218+
* (or its {shorthand form}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Shorthand+Conversion+Specifiers]
7219+
* <tt>'%c'</tt>):
71977220
*
7198-
* Returns a string in asctime(3) format (but without "\n\0" at the
7199-
* end). This method is equivalent to strftime('%c').
7221+
* Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
72007222
*
7201-
* See also asctime(3) or ctime(3).
7223+
* See {asctime}[https://linux.die.net/man/3/asctime].
7224+
*
7225+
* Date#ctime is an alias for Date#asctime.
72027226
*/
72037227
static VALUE
72047228
d_lite_asctime(VALUE self)
@@ -7208,10 +7232,15 @@ d_lite_asctime(VALUE self)
72087232

72097233
/*
72107234
* call-seq:
7211-
* d.iso8601 -> string
7212-
* d.xmlschema -> string
7235+
* iso8601 -> string
7236+
*
7237+
* Equivalent to #strftime with argument <tt>'%Y-%m-%d'</tt>
7238+
* (or its {shorthand form}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html#label-Shorthand+Conversion+Specifiers]
7239+
* <tt>'%F'</tt>);
72137240
*
7214-
* This method is equivalent to strftime('%F').
7241+
* Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
7242+
*
7243+
* Date#xmlschema is an alias for Date#iso8601.
72157244
*/
72167245
static VALUE
72177246
d_lite_iso8601(VALUE self)
@@ -7221,9 +7250,13 @@ d_lite_iso8601(VALUE self)
72217250

72227251
/*
72237252
* call-seq:
7224-
* d.rfc3339 -> string
7253+
* rfc3339 -> string
7254+
*
7255+
* Equivalent to #strftime with argument <tt>'%FT%T%:z'</tt>;
7256+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
7257+
*
7258+
* Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00"
72257259
*
7226-
* This method is equivalent to strftime('%FT%T%:z').
72277260
*/
72287261
static VALUE
72297262
d_lite_rfc3339(VALUE self)
@@ -7233,10 +7266,14 @@ d_lite_rfc3339(VALUE self)
72337266

72347267
/*
72357268
* call-seq:
7236-
* d.rfc2822 -> string
7237-
* d.rfc822 -> string
7269+
* rfc2822 -> string
7270+
*
7271+
* Equivalent to #strftime with argument <tt>'%a, %-d %b %Y %T %z'</tt>;
7272+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
7273+
*
7274+
* Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
72387275
*
7239-
* This method is equivalent to strftime('%a, %-d %b %Y %T %z').
7276+
* Date#rfc822 is an alias for Date#rfc2822.
72407277
*/
72417278
static VALUE
72427279
d_lite_rfc2822(VALUE self)
@@ -7246,10 +7283,13 @@ d_lite_rfc2822(VALUE self)
72467283

72477284
/*
72487285
* call-seq:
7249-
* d.httpdate -> string
7286+
* httpdate -> string
7287+
*
7288+
* Equivalent to #strftime with argument <tt>'%a, %d %b %Y %T GMT'</tt>;
7289+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
7290+
*
7291+
* Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
72507292
*
7251-
* This method is equivalent to strftime('%a, %d %b %Y %T GMT').
7252-
* See also RFC 2616.
72537293
*/
72547294
static VALUE
72557295
d_lite_httpdate(VALUE self)
@@ -7300,11 +7340,13 @@ jisx0301_date_format(char *fmt, size_t size, VALUE jd, VALUE y)
73007340

73017341
/*
73027342
* call-seq:
7303-
* d.jisx0301 -> string
7343+
* jisx0301 -> string
73047344
*
7305-
* Returns a string in a JIS X 0301 format.
7345+
* Returns a string representation of the date in +self+
7346+
* in JIS X 0301 format.
7347+
*
7348+
* Date.new(2001, 2, 3).jisx0301 # => "H13.02.03"
73067349
*
7307-
* Date.new(2001,2,3).jisx0301 #=> "H13.02.03"
73087350
*/
73097351
static VALUE
73107352
d_lite_jisx0301(VALUE self)

0 commit comments

Comments
 (0)