Project

General

Profile

Actions

Bug #6491

closed

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

Added by zombor (Jeremy Bush) over 10 years ago. Updated about 9 years ago.

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

Description

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

Updated by naruse (Yui NARUSE) over 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to tadf (tadayoshi funaba)

Updated by tadf (tadayoshi funaba) over 10 years ago

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

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

this is not a bug, not an incorrect format.

Updated by zombor (Jeremy Bush) over 10 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.

Updated by zombor (Jeremy Bush) over 10 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.

Updated by tadf (tadayoshi funaba) over 10 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.

Updated by zombor (Jeremy Bush) over 10 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.

Updated by tadf (tadayoshi funaba) over 10 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.

Updated by kenips (Ken Ip) about 9 years ago

@tadf (tadayoshi funaba) 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?

Actions

Also available in: Atom PDF