summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-17 12:07:07 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-17 12:07:07 +0000
commit88939df4dd452a3667d57ffc1d4480367a8ebbd4 (patch)
treea69e8a30a6994d69444e0a9426aedb278fa938a3 /lib
parent55e8ae70a032e49cf79e75e151ed8fa74e5eb145 (diff)
* lib/date.rb (Date::Infinity#<=>): didn't work. A patch from
Dirkjan Bussink <d.bussink AT gmail.com> [ruby-core:15098]. This is a bug obviously. However it didn't affect the library's functions. * lib/date.rb, lib/date/format.rb: some trivial changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/date.rb8
-rw-r--r--lib/date/format.rb6
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/date.rb b/lib/date.rb
index 2ccc311f42..7ff2895445 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -6,7 +6,7 @@
# Documentation: William Webber <william@williamwebber.com>
#
#--
-# $Id: date.rb,v 2.36 2008-01-12 10:54:29+09 tadf Exp $
+# $Id: date.rb,v 2.37 2008-01-17 20:16:31+09 tadf Exp $
#++
#
# == Overview
@@ -275,8 +275,8 @@ class Date
def <=> (other)
case other
- when Infinity; d <=> other.d
- when Numeric; d
+ when Infinity; return d <=> other.d
+ when Numeric; return d
else
begin
l, r = other.coerce(self)
@@ -524,7 +524,7 @@ class Date
if Integer === h && Integer === min && Integer === s
Rational(h * 3600 + min * 60 + s, 86400) # 4p
else
- h.to_r/24 + min.to_r/1440 + s.to_r/86400
+ (h * 3600 + min * 60 + s).to_r/86400 # 4p
end
end
end
diff --git a/lib/date/format.rb b/lib/date/format.rb
index 22126e6f7c..f89c1344a9 100644
--- a/lib/date/format.rb
+++ b/lib/date/format.rb
@@ -1,5 +1,5 @@
# format.rb: Written by Tadayoshi Funaba 1999-2008
-# $Id: format.rb,v 2.42 2008-01-12 10:54:29+09 tadf Exp $
+# $Id: format.rb,v 2.43 2008-01-17 20:16:31+09 tadf Exp $
require 'rational'
@@ -257,12 +257,12 @@ class Date
when 'j'; emit_n(yday, 3, f)
when 'k'; emit_a(hour, 2, f)
when 'L'
- emit_n((sec_fraction / MILLISECONDS_IN_DAY).round, 3, f)
+ emit_n((sec_fraction / MILLISECONDS_IN_DAY).floor, 3, f)
when 'l'; emit_a((hour % 12).nonzero? || 12, 2, f)
when 'M', 'OM'; emit_n(min, 2, f)
when 'm', 'Om'; emit_n(mon, 2, f)
when 'N'
- emit_n((sec_fraction / NANOSECONDS_IN_DAY).round, 9, f)
+ emit_n((sec_fraction / NANOSECONDS_IN_DAY).floor, 9, f)
when 'n'; "\n"
when 'P'; emit_ad(strftime('%p').downcase, 0, f)
when 'p'; emit_au(if hour < 12 then 'AM' else 'PM' end, 0, f)