Project

General

Profile

Bug #13193

[DOC] Revise docs for Date and DateTime

Added by stomar (Marcus Stollsteimer) about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [i686-linux]
[ruby-core:79433]

Description

ext/date/date_core.c: [DOC] revise docs for Date and DateTime

* fix malformed rdoc for Date#today, Date._strptime,
  and DateTime._strptime
* add code examples for Date#<< and Date#>> to demonstrate
  that different dates can result in the same return value
* use Date::ITALY in call-seq instead of only ITALY
* fix some copy/paste mistakes where Date should be DateTime
* fix various errors and grammar
* fix cross references and formatting

Files

doc_date_datetime.patch (34.1 KB) doc_date_datetime.patch stomar (Marcus Stollsteimer), 02/05/2017 09:50 AM

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

Thank you for the great contribution.
Just curious what differs in examples of Jan 30 and Jan 31.

+ *    Date.new(2001,1,30) >>  1   #=> #<Date: 2001-02-28 ...>
+ *    Date.new(2001,1,31) >>  1   #=> #<Date: 2001-02-28 ...>

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

To "demonstrate that different dates can result in the same return value", isn't Date.new(2001,1,28) better?

#3

Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset r57549.


date_core.c: [DOC] revise docs [ci skip]

  • fix malformed rdoc for Date#today, Date._strptime, and DateTime._strptime
  • add code examples for Date#<< and Date#>> to demonstrate that different dates can result in the same return value
  • use Date::ITALY in call-seq instead of only ITALY
  • fix some copy/paste mistakes where Date should be DateTime
  • fix various errors and grammar
  • fix cross references and formatting

[ruby-core:79433] [Bug #13193]
Author: Marcus Stollsteimer sto.mar@web.de

Updated by stomar (Marcus Stollsteimer) about 3 years ago

Nobuyoshi Nakada wrote:

To "demonstrate that different dates can result in the same return value", isn't Date.new(2001,1,28) better?

Agreed.
Maybe there even should be an extra paragraph that explicitly points this out.

And maybe also the following, possibly surprising sort of behavior should be mentioned:

require "date"

date = Date.new(2001,1,31)
12.times { date >>= 1 }
date.to_s   # => "2002-01-28"

date = Date.new(2001,1,31)
date >>= 12
date.to_s   # => "2002-01-31"

Should I prepare a patch?

Updated by stomar (Marcus Stollsteimer) about 3 years ago

A shorter version:

Date.new(2001,1,31) >> 2        # => #<Date: 2001-03-31 ...>
Date.new(2001,1,31) >> 1 >> 1   # => #<Date: 2001-03-28 ...>

Update: See #13225.

Updated by naruse (Yui NARUSE) almost 3 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE

ruby_2_4 r57904 merged revision(s) 57549.

Updated by nagachika (Tomoyuki Chikanaga) almost 3 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE

Updated by usa (Usaku NAKAMURA) almost 3 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE to 2.2: DONE, 2.3: REQUIRED, 2.4: DONE

ruby_2_2 r58101 merged revision(s) 57549.

Also available in: Atom PDF