Project

General

Profile

Actions

Feature #4148

closed

Time#strftime with %T broken on Windows

Added by metakeule (Marc Rene Arns) almost 14 years ago. Updated almost 11 years ago.

Status:
Closed
Assignee:
-
Target version:
[ruby-core:33664]

Description

=begin
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.
=end

Actions #1

Updated by metakeule (Marc Rene Arns) almost 14 years ago

=begin
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")

=end

Actions #2

Updated by metakeule (Marc Rene Arns) almost 14 years ago

=begin
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...
=end

Actions #3

Updated by shyouhei (Shyouhei Urabe) almost 14 years ago

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

=begin
moved.
=end

Actions #4

Updated by RvdBerg (René van den Berg) almost 14 years ago

=begin
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).
=end

Actions #5

Updated by usa (Usaku NAKAMURA) almost 14 years ago

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

=begin
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

=end

Updated by shyouhei (Shyouhei Urabe) almost 11 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0