Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 112f775092f1
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7574431e7e9a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 7, 2017

  1. Copy the full SHA
    29890d2 View commit details
  2. Copy the full SHA
    7574431 View commit details
Showing with 8 additions and 8 deletions.
  1. +8 −7 lib/ruby/stdlib/date.rb
  2. +0 −1 spec/tags/ruby/library/time/to_date_tags.txt
15 changes: 8 additions & 7 deletions lib/ruby/stdlib/date.rb
Original file line number Diff line number Diff line change
@@ -1879,16 +1879,17 @@ def to_time
end

def to_date
Date.civil(year, mon, mday, Date::GREGORIAN)
jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::GREGORIAN)
Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY)
end

def to_datetime(sg = Date::ITALY, klass = DateTime)
def to_datetime
jd = DateTime.__send__(:civil_to_jd, year, mon, mday, DateTime::ITALY)
fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec, 59].min) +
Rational(subsec, 86400)
of = Rational(utc_offset, 86400)
s = [sec, 59].min
ms, sub_millis = nsec.divmod(1_000_000) # expects ns precision for Time
sub_millis = Rational(sub_millis, 1_000_000) if sub_millis != 0
dt = Date::JODA::DateTime.new(1000 * to_i + ms, Date.send(:chronology, sg, of))
klass.new!(dt, of, sg, sub_millis)
DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
of, DateTime::ITALY)
end

end
1 change: 0 additions & 1 deletion spec/tags/ruby/library/time/to_date_tags.txt

This file was deleted.