Feature #4148

Time#strftime with %T broken on Windows

Added by metakeule (Marc Rene Arns) about 8 years ago. Updated about 5 years ago.

Target version:


On unix:'%T') #=> "15:33:03"'%Y') #=> "2010"'%Y %T') #=> "2010 15:33:03"'%H:%M:%S') #=> "15:33:03"

On Windows 7 (64bit) (ruby 1.8.7, patchlevel 249 i386-mingw32):'%T') #=> ""'%Y') #=> "2010"'%Y %T') #=> ""'%H:%M:%S') #=> "15:33:03"

So if %T is included in the string, everything breaks and "" is returned.
I guess that problem might also exist on other windows plattforms.
Since '%H:%M:%S' works it could be used instead, but some libraries, e.g. Rack::Session::Cookie use '%T' which leads to subtile bugs (e.g. Expire-Date for Cookies not set).

I haven't tested with ruby 1.9 maybe, this bug also exists there.



Updated by metakeule (Marc Rene Arns) about 8 years ago

A quick scan through my gems directory revealed the following places where strftime is used with %T.
Maybe someone has interest to inform the maintainers about the quickfix (I created a ticked for rack already):

./gems/1.8/gems/pg-0.9.0/Rakefile: artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL ||'%Y%m%d-%T'))
./gems/1.8/gems/rmagick-2.13.1/ext/RMagick/extconf.rb:#{"%a %d%b%y %T")}
./gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb: time.strftime("#{wday}, %d-#{mon}-%Y %T GMT")
./gems/1.8/gems/json_pure-1.4.6/tools/server.rb: "TIME" =>"%FT%T"),
./gems/1.8/gems/json-1.4.6/tools/server.rb: "TIME" =>"%FT%T"),
./site_ruby/1.8/pkgtools.rb: str_time +="%T")



Updated by metakeule (Marc Rene Arns) about 8 years ago

I am sorry, I should have reported this to ruby18 instead of Backport 87 (thought that it would mean 1.8.7)
Perhaps someone could move the ticket to the correct place. sorry for the hassle...


Updated by shyouhei (Shyouhei Urabe) about 8 years ago

  • ruby -v set to "Windows 7 (64bit) (ruby 1.8.7, patchlevel 249 i386-mingw32)"



Updated by RvdBerg (René van den Berg) about 8 years ago

The same thing seems to happen if the format string includes %P (only the uppercase P). Ruby -v output:
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]. Also confirmed on 1.8.6 (uninstalled now, not sure what the patchlevel was).


Updated by usa (Usaku NAKAMURA) about 8 years ago

  • Category set to core
  • Target version set to Ruby 1.8.8

The document clearly shows the supported specifiers of Time#strftime.
See it's rdoc.

So, this is not bug but feature request.

# FYI: ruby 1.9 supports %T and %P, of course on Windows

Updated by shyouhei (Shyouhei Urabe) about 5 years ago

  • Description updated (diff)
  • Status changed from Open to Closed

This target version no lnger exists. I'd like to take this opportunity to thank you all.

Also available in: Atom PDF