通过电话号码获取当前时间 [英] Get current time with a phone number

查看:24
本文介绍了通过电话号码获取当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个 RoR 移动应用程序,它可以为我提供给定电话号码在该国的当前时间及其区号.有什么好的api吗?

I want to write an RoR mobile app which gives me the current time at the country for a given phone number, with its area code. Is there a good api for this?

推荐答案

不是个好主意.

对于有多个不同时区和多个区号的国家/地区,您会怎么做?时区到区号不一定是一对一的映射.

What will you do for countries that have several different time zones and many area codes? There isn't necessarily a one-to-one mapping of time zone to area code.

例如,在美国,928 区号覆盖了亚利桑那州的大部分地区,包括两个不同的时区,因为在该州的东北部,纳瓦霍族实行夏令时,而亚利桑那州的其他地区则没有.因此,在一年中的部分时间里,928 区号的两个不同部分之间存在一小时的差异.

For example, in the USA, the 928 area code covers much of Arizona, including two different time zones because in the north-eastern portion of the state, the Navajo nation honors daylight savings time while the rest of Arizona does not. So for part of the year there is a one hour difference between two different parts of the 928 area code.

一个更简洁的例子 - 605 区号覆盖了整个南达科他州.该州西半部使用山区时间,该州东半部使用中部时间.

A cleaner example - the 605 area code covers the entire state of South Dakota. The western half of the state uses Mountain Time, and the eastern half of the state uses Central Time.

我敢肯定,在美国以外还有很多例子.

I'm sure outside of the USA there are plenty of more examples.

此外,人们带着手机旅行.我知道有 3 个人在搬到新电话号码后使用不同的区号保留他们的电话号码.

Also, people travel with their mobile phones. I know 3 people of the top of my head that kept their phone number with a different area code after moving to a new one.

此外,手机号码可携带性本地号码可携带性 允许人们搬到其他地区并保留他们的电话号码 - 包括区号.因此,区号只会告诉您号码最初来自哪里,而不是现在.

Also, Mobile Number Portability and Local Number Portability allow for people to move into other areas and keep their phone numbers - including area code. Thus area code only will tell you where the number first originated, not where it currently is.

这篇关于通过电话号码获取当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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