1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

synchronized with date2 3.6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2004-03-20 00:48:19 +00:00
parent 610b5d7975
commit f2d983cb8d
3 changed files with 41 additions and 12 deletions

View file

@ -6,7 +6,7 @@
# Documentation: William Webber <william@williamwebber.com>
#
#--
# $Id: date.rb,v 2.11 2004-01-19 04:56:12+09 tadf Exp $
# $Id: date.rb,v 2.12 2004-03-20 08:05:13+09 tadf Exp $
#++
#
# == Overview
@ -1196,16 +1196,18 @@ class DateTime < Date
def self.new_with_hash(elem, sg)
elem ||= {}
y, m, d, h, min, s, of =
elem.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset)
y, m, d, h, min, s, fr, of =
elem.values_at(:year, :mon, :mday,
:hour, :min, :sec, :sec_fraction, :offset)
h ||= 0
min ||= 0
s ||= 0
fr ||= 0
of ||= 0
if [y, m, d].include? nil
raise ArgumentError, 'invalid date'
else
civil(y, m, d, h, min, s, of.to_r/86400, sg)
civil(y, m, d, h, min, s, of.to_r/86400, sg) + (fr/86400)
end
end