Permalink
Browse files

Kosovo, US, Western Sahara

  • Loading branch information...
1 parent 1ce6060 commit 7df344af5d03ebfe6466e92c1b72005ebd5e0169 @DrHyde DrHyde committed Jul 8, 2011
Showing with 107 additions and 75 deletions.
  1. +16 −0 CHANGELOG
  2. +77 −74 lib/Number/Phone/Country.pm
  3. +14 −1 t/50_number-phone-country.t
View
@@ -1,3 +1,19 @@
+2011-XX-XX 1.8XXX Numerous small changes in Number::Phone::Country
+ Tidying number ranges in Mayotte;
+ Minor bugfix for Mayotte;
+ Gibraltar can't be called in the Spanish
+ numbering scheme any more;
+ Ellipsos satcomms have gone away;
+ Kazakhstan has +76 and +77 instead of random
+ bits all over +7;
+ Dominican Republic now has +1 849;
+ Western Sahara number ranges identified;
+ Kosovo (no ISO3166 country code yet, so I'm
+ temporarily using KOS, as used by the UN
+ Development Programme, see
+ wikipedia://List_of_UNDP_country_codes);
+ Canada and the US have some new codes
+
2011-05-20 1.8001 New UK allocations
2010-09-12 1.8 INCOMPATIBLE CHANGE: constructor will now return
View
@@ -4,7 +4,7 @@ use strict;
# *_codes are global so we can mock in some tests
use vars qw($VERSION %idd_codes %prefix_codes);
-$VERSION = 1.6001;
+$VERSION = 1.6002;
my $use_uk = 0;
sub import {
@@ -25,7 +25,10 @@ sub import {
# 1 => 'NANP',
# 2* checked against wtng.info 2011-07-08
- 20 => 'EG', 212 => 'MA', 213 => 'DZ', 216 => 'TN',
+ 20 => 'EG', 212 => 'MA',
+ 2125288 => 'EH', # \ from http://en.wikipedia.org/wiki/List_of_country_calling_codes#At_a_glance
+ 2125289 => 'EH', # /
+ 213 => 'DZ', 216 => 'TN',
218 => 'LY', 220 => 'GM', 221 => 'SN', 222 => 'MR',
223 => 'ML',
224 => 'GN',
@@ -57,16 +60,27 @@ sub import {
355 => 'AL', 356 => 'MT', 357 => 'CY', 358 => 'FI',
359 => 'BG', 36 => 'HU', 370 => 'LT', 371 => 'LV',
372 => 'EE', 373 => 'MD', 374 => 'AM', 375 => 'BY',
- 376 => 'AD', 377 => 'MC', 378 => 'SM', 379 => 'VA',
- 380 => 'UA', 381 => 'RS', 382 => 'ME', 385 => 'HR',
+ 376 => 'AD', 377 => 'MC',
+ 37744 => 'KOS', # from http://en.wikipedia.org/wiki/List_of_country_calling_codes#At_a_glance
+ 37745 => 'KOS',
+ 38128 => 'KOS',
+ 38129 => 'KOS',
+ 38138 => 'KOS',
+ 38139 => 'KOS',
+ 38643 => 'KOS',
+ 38649 => 'KOS',
+ 378 => 'SM', 379 => 'VA',
+ 380 => 'UA', 381 => 'RS',
+ 382 => 'ME', 385 => 'HR',
386 => 'SI',
387 => 'BA',
389 => 'MK', 39 => 'IT', 3966982 => 'VA',
# 4* checked against wtng.info 2011-07-08
40 => 'RO', 41 => 'CH', 420 => 'CZ', 421 => 'SK',
423 => 'LI',
- 43 => 'AT', 44 => 'GB', 45 => 'DK', 46 => 'SE',
+ 43 => 'AT', 44 => 'GB',
+ 45 => 'DK', 46 => 'SE',
47 => 'NO', 48 => 'PL', 49 => 'DE',
# 5* checked against wtng.info 2011-07-08
@@ -451,72 +465,57 @@ sub phone2country_and_idd {
}
# see http://www.nanpa.com/number_resource_info/area_code_maps.html
elsif($1 =~ m!^(
- 201|202|203|205|206|207|208|209|
- 210|212|213|214|215|216|217|218|219|
- 224|225|227|228|229|
- 231|234|239|
- 240|248|
- 251|252|253|254|256|
- 260|262|267|269|270|276|278|281|283|
- 301|302|303|304|305|307|308|309|
- 310|312|313|314|315|316|317|318|319|
- 320|321|323|325|
- 330|331|334|336|337|339|
- 341|347|
- 351|352|
- 360|361|369|
- 380|385|386|
- 401|402|404|405|406|407|408|409|
- 410|412|413|414|415|417|419|
- 423|424|425|
- 430|432|434|435|
- 440|442|443|445|
- 464|469|
- 470|475|478|479|
- 480|484|
- 501|502|503|504|505|507|508|509|
- 510|512|513|515|516|517|518|
- 520|
- 530|
- 540|541|
- 551|557|559|
- 561|562|563|564|567|
- 570|571|573|574|575|
- 580|585|586|
- 601|602|603|605|606|607|608|609|
- 610|612|614|615|616|617|618|619|
- 620|623|626|627|628|
- 630|631|636|
- 641|646|
- 650|651|657|659|
- 660|661|662|667|669|
- 678|679|
- 682|689|
- 701|702|703|704|706|707|708|
- 712|713|714|715|716|717|718|719|
- 720|724|727|
- 731|732|734|737|
- 740|747|
- 752|754|757|
- 760|762|763|764|765|769|
- 770|772|773|774|775|
- 781|785|786|
- 801|802|803|804|805|806|808|
- 810|812|813|814|815|816|817|818|
- 828|
- 830|831|832|835|
- 843|845|847|848|
- 850|856|857|858|859|
- 860|862|863|864|865|
- 870|872|878|
- 901|903|904|906|907|908|909|
- 910|912|913|914|915|916|917|918|919|
- 920|925|928|
- 931|935|936|937|
- 940|941|947|949|
- 951|952|954|956|959|
- 970|971|972|973|975|978|979|
- 980|984|985|989
+ 205|251|256|334|659|938|
+ 907|250|
+ 480|520|602|623|928|
+ 327|479|501|870|
+ 209|213|310|323|341|369|408|415|424|442|510|530|559|562|619|626|627|628|650|657|661|669|707|714|747|760|764|805|818|831|858|909|916|925|935|949|951|
+ 303|719|720|970|
+ 203|475|860|959|
+ 302|
+ 202|
+ 239|305|321|352|386|407|561|689|727|754|772|786|813|850|863|904|941|954|
+ 229|404|470|478|678|706|762|770|912|
+ 808|
+ 208|
+ 217|224|309|312|331|447|464|618|630|708|730|773|779|815|847|872|
+ 219|260|317|574|765|812|
+ 319|515|563|641|712|
+ 316|620|785|913|
+ 270|364|502|606|859|
+ 225|318|337|504|985|
+ 207|
+ 227|240|301|410|443|667|
+ 339|351|413|508|617|774|781|857|978|
+ 231|248|269|313|517|586|616|679|734|810|906|947|989|
+ 218|320|507|612|651|763|952|
+ 228|601|662|769|
+ 314|417|557|573|636|660|816|975|
+ 406|
+ 308|402|531|
+ 702|775|
+ 603|
+ 201|551|609|732|848|856|862|908|973|
+ 505|575|
+ 212|315|347|516|518|585|607|631|646|716|718|845|914|917|929|
+ 252|336|704|828|910|919|980|984|
+ 701|
+ 216|234|283|330|380|419|440|513|567|614|740|937|
+ 405|539|580|918|
+ 458|503|541|971|
+ 215|267|272|412|445|484|570|582|610|717|724|814|835|878|
+ 401|
+ 803|843|864|
+ 605|
+ 423|615|731|865|901|931|
+ 210|214|254|281|325|361|409|430|432|469|512|682|713|737|806|817|830|832|903|915|936|940|956|972|979|
+ 385|435|801|
+ 802|
+ 276|434|540|571|703|757|804|
+ 206|253|360|425|509|564|
+ 304|681|
+ 262|274|414|534|608|715|920|
+ 307
)$!x) {
return ('US', 1);
}
@@ -629,6 +628,10 @@ off by passing the 'noexport' constant when you use the module.
Also be aware that the ISO code for the United Kingdom is GB, not UK. If
you would prefer UK, pass the 'uk' constant.
+I have put in number ranges for Kosovo, which does not yet have an ISO
+country code. I have used KOS, as that is used by the UN Development
+Programme. This may change in the future.
+
=head1 FUNCTIONS
The following functions are available:
@@ -660,8 +663,8 @@ country.
=item phone2country($phone)
-Returns the ISO country code for a phone number. eg, for +441234567890
-it returns 'GB' (or 'UK' if you've told it to).
+Returns the ISO country code (or KOS for Kosovo) for a phone number.
+eg, for +441234567890 it returns 'GB' (or 'UK' if you've told it to).
=item phone2country_and_idd($phone)
@@ -693,7 +696,7 @@ So that's about once a month then. I'll do my best to keep it up to date.
The Yugoslavs keep changing their minds about what country they want to be
and what their ISO 3166 code and IDD prefix should be. YU? CS? RS? ME?
-God knows.
+God knows. And then there's Kosovo ...
=head1 AUTHOR
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
-use Test::More tests => 284;
+use Test::More tests => 297;
use Number::Phone::Country;
@@ -65,6 +65,8 @@ ok(phone2country('+4-4 845 00 DEVIL') eq 'GB', '+4-4 845 00 DEVIL is GB');
print "# regression tests for all other country codes start here\n";
ok(phone2country('+20123') eq 'EG', '+20 is EG');
ok(phone2country('+212123') eq 'MA', '+212 is MA');
+ok(phone2country('+2125288123') eq 'EH', '+212 5288 is EH');
+ok(phone2country('+2125289123') eq 'EH', '+212 5289 is EH');
ok(phone2country('+213123') eq 'DZ', '+213 is DZ');
ok(phone2country('+216123') eq 'TN', '+216 is TN');
ok(phone2country('+218123') eq 'LY', '+218 is LY');
@@ -164,13 +166,21 @@ ok(phone2country('+374123') eq 'AM', '+374 is AM');
ok(phone2country('+375123') eq 'BY', '+375 is BY');
ok(phone2country('+376123') eq 'AD', '+376 is AD');
ok(phone2country('+377123') eq 'MC', '+377 is MC');
+ok(phone2country('+37744123') eq 'KOS', '+377 44 is KOS');
+ok(phone2country('+37745123') eq 'KOS', '+377 45 is KOS');
ok(phone2country('+378123') eq 'SM', '+378 is SM');
ok(phone2country('+379123') eq 'VA', '+379 is VA');
ok(phone2country('+380123') eq 'UA', '+380 is UA');
ok(phone2country('+381123') eq 'RS', '+381 is RS');
+ok(phone2country('+38128123') eq 'KOS', '+381 28 is KOS');
+ok(phone2country('+38129123') eq 'KOS', '+381 29 is KOS');
+ok(phone2country('+38138123') eq 'KOS', '+381 38 is KOS');
+ok(phone2country('+38139123') eq 'KOS', '+381 39 is KOS');
ok(phone2country('+382123') eq 'ME', '+382 is ME');
ok(phone2country('+385123') eq 'HR', '+385 is HR');
ok(phone2country('+386123') eq 'SI', '+386 is SI');
+ok(phone2country('+38643123') eq 'KOS', '+386 43 is KOS');
+ok(phone2country('+38649123') eq 'KOS', '+386 44 is KOS');
ok(phone2country('+387123') eq 'BA', '+387 is BA');
ok(phone2country('+389123') eq 'MK', '+389 is MK');
ok(phone2country('+39123') eq 'IT', '+39 is IT');
@@ -249,6 +259,9 @@ ok(phone2country('+689123') eq 'PF', '+689 is PF');
ok(phone2country('+690123') eq 'TK', '+690 is TK');
ok(phone2country('+691123') eq 'FM', '+691 is FM');
ok(phone2country('+692123') eq 'MH', '+692 is MH');
+ok(phone2country('+7123') eq 'RU', '+7 is RU');
+ok(phone2country('+76123') eq 'KZ', '+76 is KZ');
+ok(phone2country('+77123') eq 'KZ', '+77 is KZ');
ok(phone2country('+800123') eq 'InternationalFreephone', '+800 is InternationalFreephone');
ok(phone2country('+808123') eq 'SharedCostServices', '+808 is SharedCostServices');
ok(phone2country('+81123') eq 'JP', '+81 is JP');

0 comments on commit 7df344a

Please sign in to comment.