Time zone abbreviation

From Ruby Core documentation:

zone ? string
Returns the name of the time zone used for time. As of Ruby 1.8, returns
“UTC” rather than “GMT” for UTC times.

t = Time.gm(2000, “jan”, 1, 20, 15, 1)
t.zone #=> “UTC”
t = Time.local(2000, “jan”, 1, 20, 15, 1)
t.zone #=> “CST”


strftime( string ) ? string

Time zone:

%Z - Time zone abbreviation name

C:>ruby -v
ruby 2.0.0p353 (2013-11-22) [x64-mingw32]
C:>irb
DL is deprecated, please use Fiddle
irb(main):001:0> Time.now
=> 2014-04-29 23:45:52 -0400
irb(main):002:0> Time.now.strftime(’%Z’)
=> “Eastern Daylight Time”
irb(main):003:0> Time.now.zone
=> “Eastern Daylight Time”
irb(main):004:0>

Is the documentation is wrong?
How do I get time zone abbreviation, “EDT” or “EST” instead of “Eastern
Daylight Time” or “Eastern Standard Time”?

Thanks

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Cannot reproduce on Debian 7 Testing (see [1]). This appears to be an
issue with Windows naming of timezones.

====
[1]


irb(main):005:0> Time.now.zone
=> “EDT”
irb(main):006:0> “#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}”
=> “2.0.0p457”


On 4/29/2014 23:58, Jon A. Lambert wrote:

“Eastern Standard Time”?

Thanks


Rylee F.
[email protected]
https://www.rylee.me
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCgAGBQJTYHj0AAoJEAWmNCH2N+MzDCkH/1jLvywsFVITFLjBfKwozYf7
H9CdzTuRq2UDNoYxRGtksXqAxIXU8tMtr9Fr4IVUYrLH7tiLXslD996z+uPs8BNh
WFlCunFogv9vtf2amJTqgRKHhQZn+g4oOY38ElQ+LBv692Xv4f2yt3eV/Ml3vHHr
GL/Iw3hG3SkLLOhLj3zLEBEElp/qemXYMNEkaXGv+ukMshVyeWcGGf7v1eAHAaLC
7oXBXlyfP5NcuE3KWpSqvc+05MjXaSWtT7qQ57ucELMHKzNQ8AmqXgpVY7trEKJ8
MblDnzM7AM4lWYGeENpHXr8v2AOP9y+tMnmLKjU3YKza+HCWbkO9qnTDjeYfs0A=
=wmgq
-----END PGP SIGNATURE-----

On Apr 29, 2014, at 21:15, Rylee F. [email protected] wrote:

Cannot reproduce on Debian 7 Testing (see [1]). This appears to be an
issue with Windows naming of timezones.

Agreed:

10001 % irb

Time.now.zone
=> “PDT”
Time.now.strftime “%Z”
=> “PDT”

(osx)

Maybe look at your OS’s settings for your locale.

Wayne B. wrote:

I looked but didn?t find any setting in Windows that allowed this, but can?t
help but wonder if this isn?t
due to how the OS is relaying the information back.

I noticed if you set TZ environment variable to the below format, you
get
the abbreviation.

C:>set TZ=EST-5EDT
C:>irb
irb(main):001:0> Time.now.zone
=> “EDT”
irb(main):002:0>

The TZ environment variable is not set on Windows by default.
If TZ is not set it’s apparently retrieved from registry under the
following
key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones

Curiously Cygwin’s default bash/cshell exports ‘TZ = America/New_York’,
using a program (tzset),
and Cygwin’s ruby does show ‘Time.now.zone’ => ‘EDT’.
I assume there’s a zone lookup table in Cygwin that its NEWLIB is using,
but not in MSys (rather… MSys is probably using MSVCRTL.DLL).

I’m guessing the only way to make it work exactly the same on all
platforms
is to include
a platform independent strftime() (or whatever is used) in ruby core
with
its own zone
abbreviation table.

Jon

On Apr 30, 2014, at 1:42, Ryan D. [email protected] wrote:

=> “PDT”

Time.now.strftime “%Z”
=> “PDT”

(osx)

Maybe look at your OS’s settings for your locale.

I just ran this both on Mac OS X and Windows and Jon is right.

Windows:

irb(main):001:0> Time.now.zone
=> “Central Daylight Time”

Mac OS X:

2.1.0 :003 > Time.now.zone
=> "CDT

I looked but didnt find any setting in Windows that allowed this, but
cant help but wonder if this isnt due to how the OS is relaying the
information back.

Wayne