有没有什么方法交付其发生在UTC的timezoneoffset的,计算时区在C#中? [英] Is there any delivered method which takes in timezoneoffset of UTC and calculate timezone in C#?

查看:193
本文介绍了有没有什么方法交付其发生在UTC的timezoneoffset的,计算时区在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话其中标准化给定的地址的服务,也给出结果在UTC偏移量(例如:-5:00等)的时区。

有没有在C#中的函数,该函数在UTC的timezoneoffset的,计算时区(三个字符,如CST,EST,PST)?


解决方案

没有。这是在任何语言的要求是不可能的,这是因为:


  1. 许多不同的时区共享相同的偏移量。


  2. 有是的时区缩写没有标准。有很多的重叠和模糊性。例如,CST具有我知道的至少5种不同的含义。


  3. 即使你限制自己到美国,你不能抵消可靠区分。例如,-5可以EST或它可以被CDT。

    甚至还有一小时,一年在那里EST和CDT都在完全相同的时间效应。例如,这发生在2014年11月2日,在1:00 AM EST和1:00 AM CDT的均有效的同时,都使用UTC-5偏移



  

我打电话其中标准化给定的地址的服务,也给出结果在UTC偏移量(例如:-5:00等)的时区。


除非服务返回偏移的的具体日期和时间的,那么它可能会骗你。也许正是返回的电流的偏移,但不固定。通过多个不同的偏移量相同的位置可以循环。

IMO,这样的服务不应该尝试解决偏移,而应该返回一个时区标识符,如美国/纽约

您或许应该阅读时区标签维基,你也可能有兴趣的in这个帖子

I am calling a service which standardizes a given address and also gives timezone of the result in UTC offset (ex: -5:00 etc).

Is there a function in C# which takes in timezoneoffset of UTC and calculate timezone(Three characters such as CST, EST, PST) ?

解决方案

No. That's an impossible request in any language, because:

  1. Many different time zones share the same offset.

  2. There is no standard for time zone abbreviations. There is a lot of overlap and ambiguity. For example, "CST" has at least 5 different meanings that I am aware of.

  3. Even if you limit yourself to the United States, you cannot reliably distinguish between offsets. For example, -5 could be EST or it could be CDT.

    There is even one hour a year where EST and CDT are BOTH in effect at the exact same time. For example, this occurred on November 2, 2014, when 1:00 AM EST and 1:00 AM CDT were both in effect simultaneously, and both used the UTC-5 offset.

I am calling a service which standardizes a given address and also gives timezone of the result in UTC offset (ex: -5:00 etc).

Unless the service is returning the offset for a specific date and time, then it could be lying to you. Perhaps it is returning the current offset, but that is not fixed. The same location can cycle through multiple different offsets.

IMO, Services like that should not attempt to resolve an offset, but should instead return a time zone identifier, such as America/New_York.

You should probably read the timezone tag wiki, and you may also be interested in this post.

这篇关于有没有什么方法交付其发生在UTC的timezoneoffset的,计算时区在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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