From: Marcus Stollsteimer Date: 2012-06-28T17:21:07+09:00 Subject: [ruby-core:45935] Re: [ruby-trunk - Bug #6656][Open] Time#strftime('%Z') should return 'UTC' instead of 'GMT' Am 28.06.2012 02:29, schrieb Tanaka Akira: > 2012/6/27 stomar (Marcus Stollsteimer) : >> >> 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): %Z - Time zone name Marcus --