summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-31 02:18:21 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-31 02:18:21 (GMT)
commitf85ff1ed8335948ef3630752e1faaed93b85be08 (patch)
tree46f79cf7a739d7f2b2537b2734cde87c16508d9a /ext/date
parent639679fe0240af3f8e3d751126467eb217ffe079 (diff)
date_core.c: fix DateTime rdoc
* ext/date/date_core.c (Init_date_core): [DOC] fix misplaced doc of DateTime. [ruby-core:74729] [Bug #12233] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/date_core.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 489cdc8..7e0059d 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -9149,67 +9149,6 @@ Init_date_core(void)
* d += 1 #=> #<Date: 2001-02-04 ...>
* d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001"
*
- *
- * == DateTime
- *
- * A subclass of Date that easily handles date, hour, minute, second and
- * offset.
- *
- * DateTime does not consider any leap seconds, does not track
- * any summer time rules.
- *
- * DateTime object is created with DateTime::new, DateTime::jd,
- * DateTime::ordinal, DateTime::commercial, DateTime::parse,
- * DateTime::strptime, DateTime::now, Time#to_datetime or etc.
- *
- * require 'date'
- *
- * DateTime.new(2001,2,3,4,5,6)
- * #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
- *
- * The last element of day, hour, minute or second can be
- * fractional number. The fractional number's precision is assumed
- * at most nanosecond.
- *
- * DateTime.new(2001,2,3.5)
- * #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
- *
- * An optional argument the offset indicates the difference
- * between the local time and UTC. For example, Rational(3,24)
- * represents ahead of 3 hours of UTC, Rational(-5,24) represents
- * behind of 5 hours of UTC. The offset should be -1 to +1, and
- * its precision is assumed at most second. The default value is
- * zero(equals to UTC).
- *
- * DateTime.new(2001,2,3,4,5,6,Rational(3,24))
- * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
- *
- * also accepts string form.
- *
- * DateTime.new(2001,2,3,4,5,6,'+03:00')
- * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
- *
- * An optional argument the day of calendar reform (start) denotes
- * a Julian day number, which should be 2298874 to 2426355 or
- * -/+oo. The default value is Date::ITALY (2299161=1582-10-15).
- *
- * DateTime object has various methods. See each reference.
- *
- * d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')
- * #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>
- * d.hour #=> 4
- * d.min #=> 5
- * d.sec #=> 6
- * d.offset #=> (7/48)
- * d.zone #=> "+03:30"
- * d += Rational('1.5')
- * #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...>
- * d = d.new_offset('+09:00')
- * #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...>
- * d.strftime('%I:%M:%S %p')
- * #=> "09:35:06 PM"
- * d > DateTime.new(1999)
- * #=> true
*/
cDate = rb_define_class("Date", rb_cObject);
@@ -9460,6 +9399,67 @@ Init_date_core(void)
/*
:markup: Markdown
+ ## DateTime
+
+ A subclass of Date that easily handles date, hour, minute, second and
+ offset.
+
+ DateTime does not consider any leap seconds, does not track
+ any summer time rules.
+
+ DateTime object is created with DateTime::new, DateTime::jd,
+ DateTime::ordinal, DateTime::commercial, DateTime::parse,
+ DateTime::strptime, DateTime::now, Time#to_datetime or etc.
+
+ require 'date'
+
+ DateTime.new(2001,2,3,4,5,6)
+ #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
+
+ The last element of day, hour, minute or second can be
+ fractional number. The fractional number's precision is assumed
+ at most nanosecond.
+
+ DateTime.new(2001,2,3.5)
+ #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
+
+ An optional argument the offset indicates the difference
+ between the local time and UTC. For example, `Rational(3,24)`
+ represents ahead of 3 hours of UTC, `Rational(-5,24)` represents
+ behind of 5 hours of UTC. The offset should be -1 to +1, and
+ its precision is assumed at most second. The default value is
+ zero(equals to UTC).
+
+ DateTime.new(2001,2,3,4,5,6,Rational(3,24))
+ #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
+
+ also accepts string form.
+
+ DateTime.new(2001,2,3,4,5,6,'+03:00')
+ #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
+
+ An optional argument the day of calendar reform (start) denotes
+ a Julian day number, which should be 2298874 to 2426355 or
+ -/+oo. The default value is `Date::ITALY` (2299161=1582-10-15).
+
+ DateTime object has various methods. See each reference.
+
+ d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')
+ #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>
+ d.hour #=> 4
+ d.min #=> 5
+ d.sec #=> 6
+ d.offset #=> (7/48)
+ d.zone #=> "+03:30"
+ d += Rational('1.5')
+ #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...>
+ d = d.new_offset('+09:00')
+ #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...>
+ d.strftime('%I:%M:%S %p')
+ #=> "09:35:06 PM"
+ d > DateTime.new(1999)
+ #=> true
+
### When should you use DateTime and when should you use Time?
It's a common misconception that [William Shakespeare][1] and