Is there any delivered method which takes in timezoneoffset of UTC and calculate timezone in C#?

前端 未结 2 1971
粉色の甜心
粉色の甜心 2020-12-21 05:22

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

2条回答
  •  隐瞒了意图╮
    2020-12-21 05:34

    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.

提交回复
热议问题