diff --git a/lib/et-orbi/time.rb b/lib/et-orbi/time.rb index cf531e9..285b808 100644 --- a/lib/et-orbi/time.rb +++ b/lib/et-orbi/time.rb @@ -168,7 +168,7 @@ def to_i def strftime(format) - format = format.gsub(/%(\/?Z|:{0,2}z)/) { |f| strfz(f) } + format = format.gsub(/%%|%(\/?Z|:{0,2}z)/) { |f| f == '%%' ? f : strfz(f) } to_time.strftime(format) end diff --git a/test/eo_time_test.rb b/test/eo_time_test.rb index c9fc480..c986c37 100644 --- a/test/eo_time_test.rb +++ b/test/eo_time_test.rb @@ -431,6 +431,17 @@ '1970-01-01 01:00:00 CET +0100 +01:00 +01:00:00') end + test 'preserves escaped timezone directives' do + + ot = EtOrbi::EoTime.new(0, 'Asia/Kolkata') + + assert( + ot.strftime('%%Z %%z %%:z %%::z %%/Z'), + '%Z %z %:z %::z %/Z') + assert ot.strftime('%%%Z'), '%IST' + assert ot.strftime('%%%%z'), '%%z' + end + test 'accepts %/Z' do assert(