diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-05 04:55:00 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-05 04:55:00 +0000 |
commit | 86c3de39edf068ab0bb36d76a8c29d14774a7384 (patch) | |
tree | faf2a1b5c88dc1f37945b89dd3af99aec9071743 /lib/date/format.rb | |
parent | 515d6293f587b333e17d9db4de75f938ec91400d (diff) | |
download | ruby-86c3de39edf068ab0bb36d76a8c29d14774a7384.tar.gz ruby-86c3de39edf068ab0bb36d76a8c29d14774a7384.tar.xz ruby-86c3de39edf068ab0bb36d76a8c29d14774a7384.zip |
"%\n" means "\n".
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/date/format.rb')
-rw-r--r-- | lib/date/format.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/date/format.rb b/lib/date/format.rb index 52eecaf2a..04fadd84a 100644 --- a/lib/date/format.rb +++ b/lib/date/format.rb @@ -1,4 +1,4 @@ -# format.rb: Written by Tadayoshi Funaba 1999-2005 +# format.rb: Written by Tadayoshi Funaba 1999-2006 # $Id: format.rb,v 2.15 2005-02-06 13:28:48+09 tadf Exp $ require 'rational' @@ -52,7 +52,7 @@ class Date def self.__strptime(str, fmt, elem) fmt.scan(/%[EO]?.|./mo) do |c| - cc = c.sub(/\A%[EO]?(.)\Z/o, '%\\1') + cc = c.sub(/\A%[EO]?(.)\z/mo, '%\\1') case cc when /\A\s/o str.sub!(/\A[\s\v]+/o, '') @@ -213,6 +213,8 @@ class Date warn("warning: %3 is deprecated; use '%F'") end return unless __strptime(str, '%F', elem) + when /\A%(.)/m + return unless str.sub!(Regexp.new('\\A' + Regexp.quote($1)), '') else return unless str.sub!(Regexp.new('\\A' + Regexp.quote(c)), '') end @@ -491,7 +493,7 @@ class Date def strftime(fmt='%F') o = '' fmt.scan(/%[EO]?.|./mo) do |c| - cc = c.sub(/^%[EO]?(.)$/o, '%\\1') + cc = c.sub(/\A%[EO]?(.)\z/mo, '%\\1') case cc when '%A'; o << DAYNAMES[wday] when '%a'; o << ABBR_DAYNAMES[wday] @@ -571,7 +573,10 @@ class Date warn("warning: %3 is deprecated; use '%F'") end o << strftime('%F') - else; o << c + when /\A%(.)/m + o << $1 + else + o << c end end o |