Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Shoud use nsec in substitution for subsec. Merged with Ruby 1…

….9." Because, now MacRuby has Time#subsec method

This reverts commit 3a63f4b.
  • Loading branch information...
commit 0cd7d0bb6a9e1c5514db48b60d5512ea99751786 1 parent c9e48eb
@Watson1978 Watson1978 authored
Showing with 5 additions and 7 deletions.
  1. +2 −2 lib/date.rb
  2. +3 −5 lib/time.rb
View
4 lib/date.rb
@@ -1790,7 +1790,7 @@ def to_date
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(nsec, 86400_000_000_000)
+ Rational(subsec, 86400)
of = Rational(utc_offset, 86400)
DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
of, DateTime::ITALY)
@@ -1820,7 +1820,7 @@ def self.now(sg=ITALY)
t = Time.now
jd = civil_to_jd(t.year, t.mon, t.mday, sg)
fr = time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
- Rational(t.nsec, 86400_000_000_000)
+ Rational(t.subsec, 86400)
of = Rational(t.utc_offset, 86400)
new!(jd_to_ajd(jd, fr, of), of, sg)
end
View
8 lib/time.rb
@@ -513,14 +513,12 @@ def httpdate
# require 'time'
#
def xmlschema(fraction_digits=0)
- sprintf('%d-%02d-%02dT%02d:%02d:%02d',
- year, mon, day, hour, min, sec) +
+ sprintf('%0*d-%02d-%02dT%02d:%02d:%02d',
+ year < 0 ? 5 : 4, year, mon, day, hour, min, sec) +
if fraction_digits == 0
''
- elsif fraction_digits <= 9
- '.' + sprintf('%09d', nsec)[0, fraction_digits]
else
- '.' + sprintf('%09d', nsec) + '0' * (fraction_digits - 9)
+ '.' + sprintf('%0*d', fraction_digits, (subsec * 10**fraction_digits).floor)
end +
if utc?
'Z'
Please sign in to comment.
Something went wrong with that request. Please try again.