This project is closed and read-only.
Backport #6656
closedTime#strftime('%Z') should return 'UTC' instead of 'GMT'
Added by stomar (Marcus Stollsteimer) about 14 years ago. Updated about 7 years ago.
Description
=begin
Time#strftime('%Z') should return 'UTC' instead of 'GMT',
as in Time#to_s and Time#zone. This is also the behaviour of Ruby 1.9.3.
irb(main):001:0> Time.utc(2012, 6, 27).to_s
=> "Wed Jun 27 00:00:00 UTC 2012"
irb(main):002:0> Time.utc(2012, 6, 27).zone
=> "UTC"
irb(main):003:0> Time.utc(2012, 6, 27).strftime('%Z')
=> "GMT"
=end
Updated by akr (Akira Tanaka) about 14 years ago
Actions
#1
[ruby-core:45922]
2012/6/27 stomar (Marcus Stollsteimer) redmine@ruby-lang.org:
Issue #6656 has been reported by stomar (Marcus Stollsteimer).
Time#strftime('%Z') should return 'UTC' instead of 'GMT',
as in Time#to_s and Time#zone. This is also the behaviour of Ruby 1.9.3.irb(main):001:0> Time.utc(2012, 6, 27).to_s
=> "Wed Jun 27 00:00:00 UTC 2012"
irb(main):002:0> Time.utc(2012, 6, 27).zone
=> "UTC"
irb(main):003:0> Time.utc(2012, 6, 27).strftime('%Z')
=> "GMT"
Ruby 1.8 uses strftime() in libc.
Ruby 1.9 uses own strftime() which %Z should produce UTC.
% ruby-1.8.7p357 -ve 'p Time.utc(2012, 6, 27).strftime("%Z")'
ruby 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
"GMT"
% ruby-1.9.3p194 -ve 'p Time.utc(2012, 6, 27).strftime("%Z")'
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
"UTC"
Do you really sure that it returns "GMT" with Ruby 1.9.3?¶
Tanaka Akira
Updated by stomar (Marcus Stollsteimer) about 14 years ago
Actions
#2
[ruby-core:45935]
Am 28.06.2012 02:29, schrieb Tanaka Akira:
2012/6/27 stomar (Marcus Stollsteimer) redmine@ruby-lang.org:
Issue #6656 has been reported by stomar (Marcus Stollsteimer).
Time#strftime('%Z') should return 'UTC' instead of 'GMT',
as in Time#to_s and Time#zone. This is also the behaviour of Ruby 1.9.3.irb(main):001:0> Time.utc(2012, 6, 27).to_s
=> "Wed Jun 27 00:00:00 UTC 2012"
irb(main):002:0> Time.utc(2012, 6, 27).zone
=> "UTC"
irb(main):003:0> Time.utc(2012, 6, 27).strftime('%Z')
=> "GMT"Ruby 1.8 uses strftime() in libc.
Ruby 1.9 uses own strftime() which %Z should produce UTC.
% ruby-1.8.7p357 -ve 'p Time.utc(2012, 6, 27).strftime("%Z")'
ruby 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
"GMT"
% ruby-1.9.3p194 -ve 'p Time.utc(2012, 6, 27).strftime("%Z")'
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
"UTC"Do you really sure that it returns "GMT" with Ruby 1.9.3?
Sorry, what I meant is:
The desired behavior would be that "UTC" is used consistently
in all 3 methods, as is already the case in Ruby 1.9.3.
At the moment, strftime('%Z') behaves differently in versions 1.8.7
and 1.9.3 and additionally even behaves in an unexpected and
most inconsistent way within 1.8.7: #strftime('%Z') and #zone
should output the same time zone name.
rdoc for Time#zone (1.8.7):
Returns the name of the time zone used for time.
As of Ruby 1.8, returns “UTC” rather than “GMT” for UTC times.
rdoc for strftime with '%Z' (1.8.7):
Marcus
Updated by akr (Akira Tanaka) about 14 years ago
Actions
#3
[ruby-core:45940]
2012/6/28 Marcus Stollsteimer sto.mar@web.de:
The desired behavior would be that "UTC" is used consistently
in all 3 methods, as is already the case in Ruby 1.9.3.
I see. I misunderstood.
However Ruby 1.8's %Z behavior is intended behavior because
Ruby 1.8 uses just a strftime() in libc.
So, this issue is a new feature request.
I guess it is difficult to implement, discuss and accept for Ruby 1.8.7
until the next (and last) Ruby 1.8.7 release.¶
Tanaka Akira
Updated by stomar (Marcus Stollsteimer) about 14 years ago
Actions
#4
[ruby-core:45941]
Am 28.06.2012 15:08, schrieb Tanaka Akira:
However Ruby 1.8's %Z behavior is intended behavior because
Ruby 1.8 uses just a strftime() in libc.
So, this issue is a new feature request.
I disagree.
A programmer should not have to worry about the implementation of
the method. Furthermore, in the documentation #strftime is not marked
as a mere wrapper for the C library's strftime().
The different behavior of strftime('%Z') and #zone / #to_s
is unexpected and seems even contradictory to the statement
in the #zone documentation, that "UTC" is used since 1.8.
Regards,
Marcus
Updated by akr (Akira Tanaka) about 14 years ago
Actions
#5
[ruby-core:45946]
2012/6/29 sto.mar@web.de:
A programmer should not have to worry about the implementation of
the method. Furthermore, in the documentation #strftime is not marked
as a mere wrapper for the C library's strftime().
Hm. It may be possible to consider it a documentation bug.¶
Tanaka Akira
Updated by ayumin (Ayumu AIZAWA) about 14 years ago
Actions
#6
- Project changed from Ruby to 2
Updated by jeremyevans0 (Jeremy Evans) about 7 years ago
Actions
#7
- Tracker changed from Bug to Backport
- Project changed from 2 to 11
- ruby -v deleted (
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux])
Updated by jeremyevans0 (Jeremy Evans) about 7 years ago
Actions
#8
- Tracker changed from Backport to Bug
- Project changed from 11 to Ruby
- Status changed from Open to Closed
- Backport set to 2.5: UNKNOWN, 2.6: UNKNOWN
Updated by jeremyevans0 (Jeremy Evans) about 7 years ago
Actions
#9
- Tracker changed from Bug to Backport
- Project changed from Ruby to 5
- Backport deleted (
2.5: UNKNOWN, 2.6: UNKNOWN)