根据时区确定电话号码?
我有一个(可能是国际)电话号码。它可能有也可能没有国家/地区代码前缀。有谁知道可以帮助我映射电话号码的数据库=>时区?我什至只想映射电话号码=>国家,因为我可能可以创建国家 =>通过抓取网络上的现有数据来确定时区。这是一个比看起来更复杂的问题;例如,我如何知道它是否是美国号码 - 例如,它是美国区号还是国际国家电话代码?
任何语言都可以;我可以移植它。
I have a (potentially international) phone number. It may or may not have a country code prefix. Does anyone know of a database that will help me map phone number => time zone? I would even just like to map phone number => country, since I can probably create country => time zone by scraping existing data on the web. This is a more complicated problem than it looks; for example, how do I know if it's a US-based number -- e.g. is it a USA area code, or an international country calling code?
Any language is fine; I can port it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,用于解析任意格式电话号码的最佳库是 libphonenumber。
由于显而易见的原因,您无法将国家/地区映射到时区。您和加利福尼亚州的某个人都在同一个国家/地区,甚至不在同一时区。其他国家甚至更广泛。
The best library I know of for parsing phone numbers in arbitrary formats is libphonenumber.
You can't map countries to time zones for what should be obvious reasons. Both you and someone in California are in the same country, you're not even in close to the same time zones. Other countries are even wider.
不。您的主要问题是许多国家/地区共享每个时区。例如英国和爱尔兰、法国、德国、意大利等。
您也许可以根据数字结构进行猜测,但恐怕最好的选择是尝试在任何新数据中获取代码。
No. Your primary problem here lwill be that lots of countries share each timezone. Eg UK and Ireland, France, Germany, ITaly etc.
You may be able to guess based on number structure, but your best bet I'm afraid is to try to get the code in any new data.