本文介绍了Ruby时区在Windows 7中返回完整格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示时区缩写.但是我的Ruby一直给我完整的形式.

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>

这是在Ruby 1.9.3p125中.在Ruby 2.0中也尝试过,结果也一样!甚至strftime("%Z")都给出了时区的完整形式,而不是缩写.

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.

但是文档中明确指出只应返回缩写.我实际上是在Windows 7

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

Time.now.strftime("%Z")还会提供完整的表格.

这是Windows吗?

Is this coz of Windows?

推荐答案

这个问题似乎是Windows特有的,因为我可以自己复制它.即使在文档中,它也指出:

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.

我环顾四周,似乎似乎找不到任何简单的解决方案,因为它是如此依赖于操作系统.

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.

这篇关于Ruby时区在Windows 7中返回完整格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 21:01