diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-22 05:28:08 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-22 05:28:08 +0000 |
| commit | 2dab2098e7cf3244f2eb323eaa35e8e0ceddd58a (patch) | |
| tree | da997935244b1e1b78a7bb084f88d4d3c0f65c48 /lib/date | |
| parent | e3f8a0959c0743f38f037f0bb0a9f11f18c9a727 (diff) | |
| download | ruby-2dab2098e7cf3244f2eb323eaa35e8e0ceddd58a.tar.gz ruby-2dab2098e7cf3244f2eb323eaa35e8e0ceddd58a.tar.xz ruby-2dab2098e7cf3244f2eb323eaa35e8e0ceddd58a.zip | |
* strftime.c (rb_strftime): supported flags and precision for most
conversions. [ruby-dev:35906]
* lib/date/format.rb (Date#strftime): left-justifies %L and %N.
[ruby-dev:35909]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/date')
| -rw-r--r-- | lib/date/format.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/date/format.rb b/lib/date/format.rb index 46d2147b8..7c500a52d 100644 --- a/lib/date/format.rb +++ b/lib/date/format.rb @@ -153,8 +153,8 @@ class Date s[0,0] = sign end - if f[:p] != '-' - s = s.rjust(f[:w], f[:p]) + if f[:w] + s = f[:n] ? s.ljust(f[:w], f[:p]) : s.rjust(f[:w], f[:p]) end if f[:s] && f[:p] != "\s" @@ -257,12 +257,18 @@ class Date 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) + f[:n] = true + w = f[:w] + s = emit_n((sec_fraction / MILLISECONDS_IN_SECOND).floor, 3, f) + w ? s[0, w] : s 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) + f[:n] = true + w = f[:w] + s = emit_n((sec_fraction / NANOSECONDS_IN_SECOND).floor, 9, f) + w ? s[0, w] : s when 'n'; "\n" when 'P'; emit_ad(strftime('%p').downcase, 0, f) when 'p'; emit_au(if hour < 12 then 'AM' else 'PM' end, 0, f) |
