From: Evan Dorn Date: 2010-07-06T10:30:59+09:00 Subject: [ruby-core:31062] [Backport #3541] strftime formatting error on Mac platform Backport #3541: strftime formatting error on Mac platform http://redmine.ruby-lang.org/issues/show/3541 Author: Evan Dorn Status: Open, Priority: Normal Category: lib The strftime command supports the %-m and %-d options for non-zero-padded month and non-zero-padded-day. However, on a mac they are only supported on DateTime and Date, but not on Time. This causes problems in, for example, Rails which extends Time to TimeWithZone. Quick demo of the problem: [18:26:49 ~]$ irb >> DateTime.now.strftime("%-m %-d") => "7 5" >> Time.now.strftime("%-m %-d") => "-m -d" >> exit [18:27:04 ~]$ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] The flaw appears to be mac-only. strftime works as expected on Debian Linux: [18:13] evan@ci ~ $ irb irb(main):001:0> Time.now.strftime("%-m %-d") => "7 5" irb(main):002:0> exit [18:15] evan@ci ~ $ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux] This is reproduceable in 1.8.7-p299: [18:27:07 ~]$ rvm use 1.8.7-p299 info: Using ruby 1.8.7 p299 [18:28:01 ~]$ irb ruby-1.8.7-p299 > Time.now.strftime("%-m %-d") => "-m -d" ruby-1.8.7-p299 > exit [18:28:13 ~]$ ruby -v ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10.4.0] It is *not* reproduceable in 1.9.1. ---------------------------------------- http://redmine.ruby-lang.org