ruby-changes:7322
From: tadf <ko1@a...>
Date: Mon, 25 Aug 2008 23:50:41 +0900 (JST)
Subject: [ruby-changes:7322] Ruby:r18841 (trunk): * lib/date/format.rb(strftime): can print with given arbitrary
tadf 2008-08-25 23:47:33 +0900 (Mon, 25 Aug 2008) New Revision: 18841 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18841 Log: * lib/date/format.rb(strftime): can print with given arbitrary precision. * lib/date/format.rb(strftime): optional flags and filed width should also affect %[nt]. Modified files: trunk/ChangeLog trunk/lib/date/format.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18840) +++ ChangeLog (revision 18841) @@ -1,3 +1,11 @@ +Mon Aug 25 23:38:17 2008 Tadayoshi Funaba <tadf@d...> + + * lib/date/format.rb(strftime): can print with given arbitrary + precision. + + * lib/date/format.rb(strftime): optional flags and filed width + should also affect %[nt]. + Mon Aug 25 23:01:17 2008 Yukihiro Matsumoto <matz@r...> * compile.c (defined_expr): default defined? should return Index: lib/date/format.rb =================================================================== --- lib/date/format.rb (revision 18840) +++ lib/date/format.rb (revision 18841) @@ -257,13 +257,17 @@ when 'j'; emit_n(yday, 3, f) when 'k'; emit_a(hour, 2, f) when 'L' - emit_n((sec_fraction / MILLISECONDS_IN_SECOND).floor, 3, f) + w = f[:w] || 3 + u = 10**w + emit_n((sec_fraction * u).floor, w, 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_SECOND).floor, 9, f) - when 'n'; "\n" + w = f[:w] || 9 + u = 10**w + emit_n((sec_fraction * u).floor, w, f) + when 'n'; emit_a("\n", 0, f) when 'P'; emit_ad(strftime('%p').downcase, 0, f) when 'p'; emit_au(if hour < 12 then 'AM' else 'PM' end, 0, f) when 'Q' @@ -281,7 +285,7 @@ else emit_a(strftime('%H:%M:%S'), 0, f) end - when 't'; "\t" + when 't'; emit_a("\t", 0, f) when 'U', 'W', 'OU', 'OW' emit_n(if c[-1,1] == 'U' then wnum0 else wnum1 end, 2, f) when 'u', 'Ou'; emit_n(cwday, 1, f) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/