Project

General

Profile

Actions

Bug #3541

closed

strftime formatting error on Mac platform

Added by idahoev (Evan Dorn) almost 14 years ago. Updated almost 13 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10.4.0]
[ruby-core:31062]

Description

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

Actions #1

Updated by naruse (Yui NARUSE) almost 14 years ago

  • Status changed from Open to Third Party's Issue
  • ruby -v set to ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10.4.0]

=begin
DateTime#strftime is implemented with Ruby, so it is machine independent.
But Ruby 1.8's Time#strftime uses strftime(3), so it is machine dependent.
This is spec.

Ruby 1.9's Time#strftime uses own strftime C implementation, so it is machine independent.
But it means some extensions on some systems can't be used on 1.9.
=end

Actions

Also available in: Atom PDF

Like0
Like0