我如何知道NodaTime中城市与其时区之间的关系? [英] How can I know the relation between the city and its time zone in NodaTime?

查看:52
本文介绍了我如何知道NodaTime中城市与其时区之间的关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用NodaTime从国家/地区获取时区,但问题是一个国家/地区中是否存在多个时区.我怎么知道那个时区的城市名单?我需要知道这两个数据之间的映射.可以使用NodaTime吗?

Currently I'm using NodaTime to get the time zone from country but the problem is if there are multiple time zones in a country. How could I know the list of the cities in that time zone? I need to know do the mapping between these two data. Is it possible with NodaTime?

推荐答案

处理此问题的正确方法如下:

The correct way to handle this is as follows:

  • 查找每个位置的纬度和经度.如果是机场,请考虑使用来自 OurAirports.com 的数据.您可能也对 OpenFlights 感兴趣,但是请注意,它们还是从OurAirports.com提取数据.而且,尽管OpenFlights数据具有一些时区信息,但映射到真正的IANA时区标识符还不够准确.

  • Find latitude and longitude for each location. If these are airports, then consider using the data from OurAirports.com. You might also be interested in OpenFlights, but be aware that they source their data from OurAirports.com anyway. And while OpenFlights data has some time zone information, it's not accurate enough to map to a true IANA time zone identifier.

一旦您有了经度和纬度,就可以使用其中一种方法来查找时区从该位置开始.

Once you have longitude and latitude, then you can use one of these methods to lookup the time zone from the location.

然后您可以通过 DateTimeZoneProviders.Tzdb [theTimeZoneId]

这篇关于我如何知道NodaTime中城市与其时区之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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