This project is archived and is in readonly mode.
ActiveSupport::TimeWithZone strftime formatting lacks unpadded types
-
Evan Dorn
Attempt at better formatting:
Loading development environment (Rails 2.3.8)>> DateTime.parse("June 5th").strftime("%m %d")
=> "06 05"
>> DateTime.parse("June 5th").strftime("%-m %-d")
=> "6 5"
>> Time.zone.parse("June 5th").strftime("%m %d")
=> "06 05"
>> Time.zone.parse("June 5th").strftime("%-m %-d")
=> "-m -d"
-
Neeraj Singh
I can confirm that this is an issue with rails3 too.
-
Neeraj Singh
It seems this is a ruby issue.
$ irb irb(main):001:0> Time.now.strftime("%-m %-d") => "-m -d" irb(main):002:0> Time.now.strftime("%m %d") => "05 29" irb(main):003:0> DateTime.now.strftime("%m %d") => "05 29" irb(main):004:0> DateTime.now.strftime("%-m %-d") => "5 29" irb(main):005:0> exit nsingh@ ~ $ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0] -
Santiago Pastorino
- Milestone cleared.
- State changed from new to open
- Assigned user set to Santiago Pastorino
Can someone provide failing tests?
-
Santiago Pastorino
santiago@debian:/tmp$ irb >> Time.now.strftime("%-m %-d") => "6 3" >> Time.now.strftime("%m %d") => "06 03" >> DateTime.now.strftime("%m %d") => "06 03" >> DateTime.now.strftime("%-m %-d") => "6 3" >> santiago@debian:/tmp$ ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]Seems to be fixed on the latest ruby 1.8.7, please check this. -
Santiago Pastorino
- State changed from open to invalid
I'm closing this ticket if you have troubles please mention again and i will reopen
-
Evan Dorn
- Importance changed from to Low
It's not the version of Ruby that matters. It's the platform. Works on linux, doesn't work on Mac.
On a mac, Snow Leopard installed:
[18:12:52 ~]$ irb ruby-1.8.7-p299 > Time.now.strftime("%-m %-d")
=> "-m -d" [18:13:25 ~]$ ruby -v ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10.4.0]On a Ubuntu linux machine:
[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] -
Evan Dorn
Since it appears to be a platform-dependent Ruby issue, I reported this to the Ruby error tracker: http://redmine.ruby-lang.org/issues/show/3541
-
Santiago Pastorino
Ok you're right Evan, and yeah reporting to ruby is the right way to go, thanks ;).