Project

General

Profile

Actions

Bug #13193

closed

[DOC] Revise docs for Date and DateTime

Bug #13193: [DOC] Revise docs for Date and DateTime

Added by stomar (Marcus Stollsteimer) over 8 years ago. Updated over 8 years ago.

Status:
Closed
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) over 8 years ago Actions #1 [ruby-core:79442]

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) over 8 years ago Actions #2 [ruby-core:79456]

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

Updated by nobu (Nobuyoshi Nakada) over 8 years ago Actions #3

  • 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

Updated by stomar (Marcus Stollsteimer) over 8 years ago Actions #4 [ruby-core:79460]

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) over 8 years ago Actions #5 [ruby-core:79461]

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) over 8 years ago Actions #6 [ruby-core:80051]

  • 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) over 8 years ago Actions #7 [ruby-core:80093]

  • 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) over 8 years ago Actions #8 [ruby-core:80333]

  • 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.

Actions

Also available in: PDF Atom