ntp时间同步会同步时区吗_如何处理时区并使软件与国际客户同步

ntp时间同步会同步时区吗

When you develop some software you may not think about timezones at first. Unless you live in a country which has to deal with multiple time zones, such as the United States or Russia.

当您开发某些软件时,您可能首先不会考虑时区。 除非您居住在必须处理多个时区的国家/地区,例如美国或俄罗斯。

I recently came across an issue involving timezones. There were some unit tests making assertions about dates that used to work at my office in France but weren't working in Morocco for new members on our team.

我最近遇到了一个涉及时区的问题。 有一些单元测试对以前在法国的办公室工作但对摩洛哥的新成员不起作用的日期作出断言。

‌This was an opportunity for me to learn how to correctly handle dates and times for international software. In this article, I’ll introduce time zone issues and share some rules to follow.

‌这对我来说是一个学习如何正确处理国际软件日期和时间的机会。 在本文中,我将介绍时区问题并分享一些要遵循的规则。

快速介绍时区 (Quick introduction to time zones)

As the earth is kind of a sphere, the sun is rising in Japan while it's setting in America. If everyone used global time, let’s say 09:00 would be sunrise in Japan, but for Americans it would be sunset. Not very handy.

由于地球是一个球体,因此日本落日于美国时太阳正在升起。 如果每个人都使用全球时间,那么假设09:00在日本是日出,但对美国人来说则是日落。 不太方便。

To make sure the time is coordinated with the sun for everyone, it’s necessary to shift from global time according to your location. As a result, the globe gets split into time zones and each gets an offset. This offset is a number of minutes to add to the global time to get your time zone time. It can be either positive or negative.

为了确保所有人的时间都与太阳协调,有必要根据您所在的位置从全球时间转变。 结果,地球仪分为多个时区 ,每个时区都有一个偏移量 。 此偏移量是要添加到全局时间以获取您的时区时间的分钟数。 它可以是正数或负数。

Global time is called UTC, it stands for Coordinated Universal Time. You may also heard about GMT which is a time zone without any offset.

全球时间称为UTC 它表示世界协调时间。 您可能还听说过GMT ,这是一个没有任何偏移的时区。

For instance, when it’s 10:50 at UTC, it’s also  03:50 in San Francisco with a -0700 offset and 18:50 in Beijing with a +0800 offset. Yet, the shift isn’t only in whole hours: Nepal's offset is +0545. You can check it out on Wikipedia.

例如,在世界标准时间10:50时,在旧金山也是03:50 ,偏移为-0700 ,在北京为18:50 ,偏移+0800 。 但是,这种变化不仅发生在整个小时内:尼泊尔的偏移量是+0545 。 您可以在Wikipedia上查看。

In addition of this offset, which comes with the time zone, some countries also shift clocks twice a year. DST or summer time adds one hour to the time zone offset before summer. Then, the clock is reset to the time zone time in winter. The goal is to make the daytime longer.

除了时区带来的这种偏移外,某些国家/地区还每年两次偏移时钟。 DST或夏令时会使夏令时之前的时区偏移量增加一小时。 然后,将时钟重置为冬季的时区时间。 目标是延长白天。

The most common way to figure out a time zone is by using the IANA Time Zone Database. You end up with a string such as Europe/Paris following the Area/City pattern. Besides, Microsoft maintains its own Microsoft Time Zone Database used on its operating systems. But this can cause issues when running cross-platform .NET Core apps.

找出时区的最常见方法是使用IANA时区数据库 。 您最终

你可能感兴趣的:(数据库,python,java,大数据,人工智能)