[macruby-changes] [4571] MacRuby/trunk/lib
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 4 15:47:44 PDT 2010
Revision: 4571
http://trac.macosforge.org/projects/ruby/changeset/4571
Author: watson1978 at gmail.com
Date: 2010-10-04 15:47:43 -0700 (Mon, 04 Oct 2010)
Log Message:
-----------
Shoud use nsec in substitution for subsec. Merged with Ruby 1.9.
- Fixed the #926, #927
Modified Paths:
--------------
MacRuby/trunk/lib/date.rb
MacRuby/trunk/lib/time.rb
Modified: MacRuby/trunk/lib/date.rb
===================================================================
--- MacRuby/trunk/lib/date.rb 2010-10-04 22:47:39 UTC (rev 4570)
+++ MacRuby/trunk/lib/date.rb 2010-10-04 22:47:43 UTC (rev 4571)
@@ -1787,7 +1787,7 @@
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)
+ Rational(nsec, 86400_000_000_000)
of = Rational(utc_offset, 86400)
DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
of, DateTime::ITALY)
@@ -1817,7 +1817,7 @@
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.subsec, 86400)
+ Rational(t.nsec, 86400_000_000_000)
of = Rational(t.utc_offset, 86400)
new!(jd_to_ajd(jd, fr, of), of, sg)
end
Modified: MacRuby/trunk/lib/time.rb
===================================================================
--- MacRuby/trunk/lib/time.rb 2010-10-04 22:47:39 UTC (rev 4570)
+++ MacRuby/trunk/lib/time.rb 2010-10-04 22:47:43 UTC (rev 4571)
@@ -513,12 +513,14 @@
# require 'time'
#
def xmlschema(fraction_digits=0)
- sprintf('%0*d-%02d-%02dT%02d:%02d:%02d',
- year < 0 ? 5 : 4, year, mon, day, hour, min, sec) +
+ sprintf('%d-%02d-%02dT%02d:%02d:%02d',
+ year, mon, day, hour, min, sec) +
if fraction_digits == 0
''
+ elsif fraction_digits <= 9
+ '.' + sprintf('%09d', nsec)[0, fraction_digits]
else
- '.' + sprintf('%0*d', fraction_digits, (subsec * 10**fraction_digits).floor)
+ '.' + sprintf('%09d', nsec) + '0' * (fraction_digits - 9)
end +
if utc?
'Z'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101004/5e32e3b9/attachment-0001.html>
More information about the macruby-changes
mailing list