Bug #6491

DateTime.strftime('%Z') output is incorrect format

Added by Jeremy Bush almost 2 years ago. Updated 9 months ago.

[ruby-core:45220]
Status:Rejected
Priority:Low
Assignee:tadayoshi funaba
Category:-
Target version:-
ruby -v:ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11] Backport:

Description

DateTime.parse('2012/05/23').strftime('%Z') should output 'GMT' (or a similar string). It outputs "+00:00" (or a similar offset string).

History

#1 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to tadayoshi funaba

#2 Updated by tadayoshi funaba almost 2 years ago

  • Status changed from Assigned to Rejected
  • Priority changed from Normal to Low

i don't know how to determine such a name.
moreover, GMT is already dead.

this is not a bug, not an incorrect format.

#3 Updated by Jeremy Bush almost 2 years ago

Time.parse().strftime('%Z') outputs UTC. Notice I said "similar format". It should output a human consumable output like Time.strftime('%Z') does. If nothing else, the two identically named functions output two different things.

#4 Updated by Jeremy Bush almost 2 years ago

And if it's not a bug, what's the difference between %:z and %Z? Currently they basically output the same thing. The documentation says: %Z - Time zone abbreviation name.

#5 Updated by tadayoshi funaba almost 2 years ago

i tried to avoid the term of UTC or similar words here carefully.
because, we use +00:00 as a local time.

ruby's Time object has a mode UTC/local time.
but, DateTime does not so.
DateTime does not have the obvious local time zone.

incorrect?
i don't think so.
iso8601 is a human readable format.

#6 Updated by Jeremy Bush almost 2 years ago

If this is expected functionality, then perhaps the documentation should be changed. It clearly says %Z - Time zone abbreviation name. This in my eyes (and about 10 other ruby developers I asked before i filed this) means UTC, CST, etc.

It may be a human readable format, but it sure isn't the "Time zone abbreviation name" as the documentation says.

#7 Updated by tadayoshi funaba almost 2 years ago

Time's one also says.
but, actually it depends on platform.
on windows, may not always return abbreviation.

this may be a matter of common sense.
but, it's not so good for novice.

#8 Updated by Ken Ip 9 months ago

@tadf why is this closed? To me a discrepancy between DateTime.strftime and Time.strftime should either be documented or fixed. You're saying that:

DateTime.now.strftime('%z %Z')
=> "-0400 -04:00"

Time.now.strftime('%z %Z')
=> "-0400 EDT"

is OK?

Also available in: Atom PDF