Ruby Time zone returns full form in windows 7

与世无争的帅哥 提交于 2019-12-10 11:41:38

问题


I want to display the Timezone abbreviation. But my Ruby keeps giving me the fullform.

irb(main):001:0> Time.now
=> 2014-02-28 15:11:21 +0530
irb(main):002:0> Time.now.zone
=> "India Standard Time"
irb(main):003:0>

This was in Ruby 1.9.3p125. Tried in Ruby 2.0 as well and same results! Even strftime("%Z") gives full form of the time zone and not the abbreviation.

But the documentation clearly states that only the abbreviation should be returned. I am actually building a rhodes application on Windows 7

EDIT: Time.now.strftime("%Z") also gives full form.

Is this coz of Windows?


回答1:


This issue does seem to be Windows specific as I was able to reproduce it myself. Even in the documentation, it states:

Also, %Z is highly dependent on the operating system. For example, it may generate a non ASCII string on Japanese Windows. i.e. the result can be different to “JST”.

I looked around and I couldn't seem to find any simple solution to this as it is so dependent on the operating system.



来源:https://stackoverflow.com/questions/22092281/ruby-time-zone-returns-full-form-in-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!