Feature #4148
Time#strftime with %T broken on Windows
| Status: | Open | Start date: | 12/10/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | core | |||
| Target version: | Ruby 1.8.8 |
Description
On unix:
Time.now.strftime('%T') #=> "15:33:03"
Time.now.strftime('%Y') #=> "2010"
Time.now.strftime('%Y %T') #=> "2010 15:33:03"
Time.now.strftime('%H:%M:%S') #=> "15:33:03"
On Windows 7 (64bit) (ruby 1.8.7, patchlevel 249 i386-mingw32):
Time.now.strftime('%T') #=> ""
Time.now.strftime('%Y') #=> "2010"
Time.now.strftime('%Y %T') #=> ""
Time.now.strftime('%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.
History
Updated by metakeule (Marc Rene Arns) over 1 year 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 || Time.now.strftime('%Y%m%d-%T'))
./gems/1.8/gems/rmagick-2.13.1/ext/RMagick/extconf.rb:#{DateTime.now.strftime("%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" => Time.now.strftime("%FT%T"),
./gems/1.8/gems/json-1.4.6/tools/server.rb: "TIME" => Time.now.strftime("%FT%T"),
./site_ruby/1.8/pkgtools.rb: str_time += Time.at(time).utc.strftime("%T")
Updated by metakeule (Marc Rene Arns) over 1 year 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) over 1 year ago
- ruby -v set to "Windows 7 (64bit) (ruby 1.8.7, patchlevel 249 i386-mingw32)"
moved.
Updated by RvdBerg (René van den Berg) over 1 year 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) over 1 year 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