修复夏季或冬季需要增加或减少一小时的国家的时区。

huangapple go评论83阅读模式
英文:

Fix time zone in countries thats add and subtract one hour when is summer or winter

问题

我有一个问题,有一个系统负责在未来的某个特定日期发送消息,就像一个时间限制一样。这个系统位于另一个国家,其时区为-4小时,而接收消息的国家位于-3小时的时区。这两个国家分别是智利和巴西。问题是,当这些国家进入夏令时时,它们会增加一小时,但是在不同的日期。在一个为期4个月的时间段内,它们具有相同的时区。因此,为了在正确的时间发送消息,我需要在时区为-4和-3的日期上增加一小时,但当时区匹配-3小时时,我不需要做任何操作。

对于这个任务,我想使用函数time.LoadLocation("America/Sao_Paulo"),但是阅读文档时没有提到它们是否会调整时区,当这些国家改变时区时。

有人知道他们是否会调整时区,或者知道另一个在这种情况下可以工作的函数吗?

英文:

i have this problem, there is a system thats has the duty to deliver a message in the future in a certain date, like a time limit, so this system is in another country thats have the time zone -4 hours and the country thats recibe the message is in a time zone -3 hours, for this country are Chile and Brazil, the problem is, this countries when they enter to the summer time they add one hour, but in different dates, for a period of time like 4 months thy have the same time zone, so for me to deliver the message in the right time i have to add one hour to the date in when the time zone are in -4 and - 3 but when the time zone match -3 hours i dont have to do nothing.

for this task i want to use the function time.LoadLocation("America/Sao_Paulo"), but reading the documentation dosen't mention if they fix the time zone when this countries change their time zone.

does anyone know if they adjust the time zone, or know another function thats can work in this situation?

答案1

得分: 1

遵循夏令时的地区不会改变时区,而是改变时间标准。例如,洛杉矶在大部分时间与协调世界时(UTC)相差8小时,但在夏季相差7小时;然而,洛杉矶始终属于“太平洋时间”。

如果将时区设置为“America/Sao_Paulo”,时间将相对于圣保罗当时有效的时间标准来测量。

英文:

Areas that observe daylight savings time don’t change the time zone, they change the time standard. For instance, Los Angeles observes a given time eight hours before UTC for much of the year, but seven hours before UTC during the summer; yet Los Angeles is always “Pacific time”.

If you set the time zone to "America/Sao_Paulo", times will be measured relative to Sao Paulo’s then-active time standard.

huangapple
  • 本文由 发表于 2022年8月15日 05:52:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/73355330.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定