Determine phone number based on time zone? - phone-number

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.

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.

Related

NUTS Regions to UK Postcodes

I was just wondering if anybody had a reliable way to convert UK postcodes to their respective NUTS region/code?
I managed to find a .csv on eurostat's website, but their data appears to be a bit inaccurate (i.e classifying Dudley as in Scotland and using the old NUTS regions for London).
I've searched endlessly online for anything like this, but as I've only just heard of NUTS today, I'm unsure whether I'm even looking for the right thing.
The title of your question says NUTS to UK postcodes but in the body you mention UK postcodes to NUTS. I'm not sure whether you are interested in both.
There is a simple way to turn UK postcode to NUTS (both names and codes) using R:
devtools::install_github("erzk/PostcodesioR")
library(PostcodesioR)
# both will work:
postcode_query("EC1Y8LX")
postcode_lookup("EC1Y8LX")
This will return a list with geographic information about the postcodes.
Disclaimer: I'm the author of the PostcodesioR package.

Differentiate between address, city, state, zip in UISearchBar

One of the parameters my iOS application must meet is searching in full or partially by address, city, state, and zipcode.
I cannot depend on users using commas to separate the data. I also do cannot scan a string for a zip code since the street number could potentially be 5 digits.
I was wondering what standard practice was used to analyze this sort of input. Any help or reference would be greatly appreciated.
One (slightly inefficient) way of doing this would be to make a call to Google's Geocoding API. You'll get results with address component types, such as street_address, postal_code, administrative_area_level_n, etc.
Hope this helps!

Guessing the time zone from an arbitrary "location" string?

I'm trying to run some statistics over the Stack Overflow data dump, and for that I would like to know the time zone for each user. However, all I have to go on is the completely free-form "location" string.
I'll stress that I'm only looking for an approximation of the time zone; of course, in general this is an unsolvable problem. However, many people fill out their country, state and/or city, which should give a pretty good indication. It's okay if it fails for other cases. It doesn't have to be reliable, it doesn't have to be accurate, it doesn't have to cover all bases.
I don't want to waste too much time on this, so I'm wondering if there is some code out there that can make a reasonable guess. Any language, platform, API or library goes. Any ideas?
Check this discussion for information on how to get the lat/lon from an arbitrary location string.
Once you have the lat/lon, you can use the web services at GeoNames to retrieve the time zone.

Formatting phone numbers on iOS

Is there a way to format the phone numbers? For e.g. +11234567890 to +1(123) 456-789. And also is it possible to separate ISD and STD codes in the phone number itself? Since apple is doing the same in IPhone's address book and as well as Mobile application, I believe that there is way to the same (but no idea how to do).
You want NSDataFormatter and probably NSNumberFormatter. Both are classes designed to handle just this type of problem with minimum fuss.
If you handle a lot of phone numbers you might want to go ahead and write a dedicated formatting subclass just for phone numbers. I used to have one that would return properly localized phone numbers e.g. formats for North America vs Europe vs Asia etc depending on the location set for the device.
Phone numbers are one of those common pieces of data whose handling grows surprisingly complex very quickly especially when you start throwing in international variations and various types of extensions like calling cards or voice tree controls.

Detect currency based on user's location?

I am creating an international web application which users can subscribe to. I want subscription rates to vary based on the user's currency. If my user is in the US, they pay $19/month; if in China, they pay some other rate. So, I am thinking I could detect the user's location, and from their location, I can detect their currency (via a location to currency map table in my database). If I can't detect their currency, then I'll force them to enter it before displaying subscription rates.
Does this seem like an acceptable solution? Will this be pretty reliable? If not, can anyone think of a better solution?
Seems good. Geolocation is pretty reliable, and the mapping from countries to currencies should be easy. I don't know whether such a mapping is already available somewhere, though.
Just make sure that you allow users to change the currency, in case your detection fails. Or they're trying to subscribe while they happen to be abroad, or something.
how to get the location of a user might be helpful

Resources