gpt4 book ai didi

java - 时区原始偏移量

转载 作者:搜寻专家 更新时间:2023-10-31 22:14:47 24 4
gpt4 key购买 nike

在对时区进行一些研究时,我发现了这个 interesting post on the GeoNames forum :

rawOffset gives the fixed timezone.
dstOffset gives the civil time offset from GMT on July 1st
gmtOffset gives the civil time offset from GMT on January 1st

On the southern hemisphere, for example for Chile (http://ws.geonames.org/timezone?lat=-33.46912&lng=-70.641997) we have the following values:

rawOffset = -4 indicating the timezone
dstOffset = -4
gmtOffset = -3, which means that daylight saving time is in use in January.

On the northern hemisphere, for the Netherlands for example (http://ws.geonames.org/timezone?lat=51.589322&lng=4.774491):

rawOffset = 1
dstOffset = 2
gmtOffset = 1, indacting that daylight saving time is in use in July.

这也不是我第一次看到 rawOffsetthis SO answer (在 Java 中)也依赖于它。

我的目标是使用原始偏移量构建一个时区下拉菜单,显示每组城市的 UTC 偏移量,现在 I'm listing all the transitions for the timezone并使用非 DST 偏移量,但我上面提到的帖子表明这对南半球来说是错误的。


编辑: http://download.oracle.com/javase/1.4.2/docs/api/java/util/TimeZone.html#getRawOffset%28%29

GeoNames 的 Marc 告诉我,他们通过使用该 Java 方法获得原始偏移量。

任何 Java 向导都知道他们是如何做到的吗?或者我在哪里可以浏览他们的 getRawOffset() 源代码?


关于如何在 PHP 中获取原始偏移量的任何想法?

最佳答案

不清楚为什么需要原始偏移量。

在 PHP 中,给定一个时间 + 位置,您可以实例化一个 DateTime 对象,然后调用它的 getOffset() 方法来计算当前时区偏移量。遍历不同的位置,这应该是您获得下拉菜单所需的全部,不是吗?

参见 http://www.php.net/manual/en/datetime.getoffset.php

关于java - 时区原始偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7823094/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com