夏令时间隔/重叠定义?什么时候“纠正”?为了他们? [英] Daylight Savings Time Gap/Overlap definitions? When to "correct" for them?

查看:255
本文介绍了夏令时间隔/重叠定义?什么时候“纠正”?为了他们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 夏令时重叠和 差距?
    我对它们有朦胧的理解,所以我想确认...在其中任何一个内部意味着什么?

  1. What is the definition of Daylight Savings Time 'Overlap' & 'Gap'? I have a hazy understanding of them, so I'd like to confirm... What does it mean to be "within" either of them?

校正 DST间隙或DST重叠是什么意思?什么时候需要校正,什么时候不需要校正? p>

What does it mean to "correct" for DST Gap or DST Overlap? When does a time need correcting, and when does it not need correcting?

上面的问题与语言无关,但是我所应用的一个例子是:

The above questions are language-agnostic, but an example of their application I have is:


  1. 何时致电 org.joda.time.LocalDateTime#correctDstTransition

  1. When to call org.joda.time.LocalDateTime#correctDstTransition?

在DST重叠的情况下校正日期。创建的Date对象的
与该日期时间完全相同,但由于夏令时时间
无效的情况除外间隙。在这种情况下,时间
将被设置为间隔之后的最早有效时间。如果
的夏令时重叠,则选择较早的时刻。

Correct date in case of DST overlap.The Date object created has exactly the same fields as this date-time, except when the time would be invalid due to a daylight savings gap. In that case, the time will be set to the earliest valid time after the gap. In the case of a daylight savings overlap, the earlier instant is selected.



推荐答案

DST标签Wiki 中已经对此进行了解释,但是我会回答您的具体问题。

Much of this is already explained in the DST tag wiki, but I will answer your specific questions.


夏令时重叠和 'gap'?

...

都在其中一个是什么意思?

What is the definition of Daylight Savings Time 'Overlap' & 'Gap'?
...
What does it mean to be "within" either of them?

夏令时开始时,本地时间会提前-通常会增加一小时。

When daylight saving time begins, the local time is advanced - usually by one hour. This creates a "gap" in the values of local time in that time zone.


  • 例如,当DST在该时区开始时,这会在该时区的本地时间值中创建一个间隙。在美国,时钟从1:59 AM到3:00 AM。从2:00 AM到2:59 AM的任何本地时间值都将被视为在间隙内。

  • For example, when DST starts in the United States, the clocks tick from 1:59 AM to 3:00 AM. Any local time value from 2:00 AM through 2:59 AM would be considered to be "within the gap".

请注意,间隙中的值是不存在。除非时钟未正确提前,否则它们不会在现实世界中发生。实际上,通常是通过从另一个本地时间加上或减去经过的时间值来获得一个在间隔内的值。

Note that values in the gap are non-existent. They do not occur in the real world, unless a clock was not correctly advanced. In practice, one typically gets to a value within the gap by adding or subtracting an elapsed time value from another local time.

夏令时结束时,本地时间将以开始时所添加的相同时间缩回(通常为1小时)。这样会在该时区的本地时间值中产生重叠。

When daylight saving time ends, the local time is retracted by the same amount that was added when it began (again, usually 1 hour). This creates an "overlap" in the local time values of that time zone.


  • 例如,当夏令时结束于美国时州,时钟从1:59 AM滴答回到1:00 AM。如果没有其他合格信息,则从1:00 AM到1:59 AM的任何本地时间值都是不明确

To 处于重叠范围内表示您的值可能不明确,因为它属于此范围。

To be "within the overlap" means that you have a value that is potentially ambiguous because it falls into this range.

此类值可能属于白天时间发生(顺序是第一),或者可能属于标准时间发生(顺序是 second )。

Such values may belong to the daylight time occurrence (which comes first sequentially), or may belong to the standard time occurrence (which comes second sequentially).


校正 DST间隙或DST重叠是什么意思? / p>

What does it mean to "correct" for DST Gap or DST Overlap?

更正间隙意味着可以通过将本地时间值移动到其他值来确保其有效。这样做有各种各样的方案,但是最常见和最明智的方法是将本地时间值提高差距量。

Correcting for the gap means to ensure that the local time value is valid by possible moving it to a different value. There are various schemes in use for doing so, but the most common and most sensible is to advance the local time value by the amount of the gap.


  • 例如,如果您的当地时间为2:30 AM,并且确定它发生在美国的春季向前过渡的那天,那么该时间将落在空白处。将其推进到凌晨3:30。

  • For example, if you have a local time of 2:30 AM, and you determine it to occur on the day of the spring-forward transition in the United States, then it falls into the gap. Advance it to 3:30 AM.

这种方法往往效果很好,因为它模拟了人类手动推进模拟时钟的行为,或者更正了

This approach tends to work well because simulates the act of a human manually advancing an analog clock - or rather, correcting with the idea that it had not been properly advanced.

更正重叠部分意味着确保所有当地时间都很好合格。通常,这是通过为所有值分配时区偏移量来实现的。

Correcting for the overlap means to ensure that all local times are well qualified. Usually this is accomplished by assigning a time zone offset to all values.


  • 如果值不是模棱两可,

  • In the case of a value that is not ambiguous, the offset is deterministic.

如果值在回退过渡的当天落在重叠范围之内,通常选择两个可能值的 first (将具有 daylight 时间偏移)。这是因为时间向前移动。但是,有时在某些情况下使用其他规则是有意义的,所以使用YMMV。

In the case of a value that falls within the overlap on the day of a fall-back transition, it often makes sense to choose the first of the two possible values (which will have the daylight time offset). This is because time moves in a forward direction. However, there are sometimes cases where it makes sense to use a different rule, so YMMV.


什么时候需要校正,什么时候不需要校正?

When does a time need correcting, and when does it not need correcting?

如果您尝试使用时间作为时间,瞬时值,例如确定两个值之间的经过时间,将经过的时间添加到特定值,或者转换为UTC时,则需要在出现间隙和重叠时进行校正。

If you are attempting to work with time as an instantaneous value, such as determining the elapsed duration between two values, adding an elapsed time to a specific value, or when converting to UTC, then you need to correct for gaps and overlaps as they occur.

如果仅使用用户输入和输出,总是显示用户给您的确切值(并且从不将其用于数学或时区转换),则无需校正间隙和重叠

If you are only working with user input and output, always displaying the exact value a user gave you (and never using it for math or time zone conversions) then you do not need to correct for gaps and overlaps.

此外,如果您正在使用仅日期值或仅时间值,则根本不应该应用时区信息,因此不要需要纠正差距和重叠。

Also, if you are working with date-only values, or time-only values, then you should not be applying time zone information at all, and thus do not need to correct for gaps and overlaps.

最后,如果您工作严格, y与没有夏令时的协调世界时(UTC),则无需校正间隙和重叠。

Lastly, if you are working strictly with Coordinated Universal Time (UTC), which has no daylight saving time, then you do not need to correct for gaps and overlaps.


何时致电 org.joda.time.LocalDateTime#correctDstTransition

您别。该方法是 private ,并在需要时由其他Joda-time函数调用。

You don't. That method is private, and is called by other Joda-time functions as needed.

这篇关于夏令时间隔/重叠定义?什么时候“纠正”?为了他们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆