diff --git a/CHANGELOG b/CHANGELOG index 7c4e382..a265a68 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,7 +2,11 @@ X.XXXX XXXX-XX-XX - Bug fix: NANP toll-free numbers corrected. 833 area code now supported, and regex fixed to only match when the B and C digits are the same, so - 800 is toll-free, 888 is toll-free, but 808 is not. + 800 is toll-free, 888 is toll-free, but 808 is not. See + https://github.com/DrHyde/perl-modules-Number-Phone/issues/110 + +- Bug fix: NANP 1-600 area code is non-geographic. See + https://github.com/DrHyde/perl-modules-Number-Phone/issues/113 - Workaround: OFCOM have the wrong number length for the +44 800 716 range, we now have an egregious hack to work around that. See diff --git a/lib/Number/Phone/NANP.pm b/lib/Number/Phone/NANP.pm index 0ce6726..1780cc2 100644 --- a/lib/Number/Phone/NANP.pm +++ b/lib/Number/Phone/NANP.pm @@ -173,6 +173,9 @@ not yet be allocated, or it may be reserved. NANP-globals like 1-800 aren't geographic, the rest are. +As a special case, 1-600 is non-geographic. So too will be +1-622/633/644/655/677/688 when they come in to service. + =item is_mobile NANP-globals like 1-800 aren't mobile. For most others we just don't know because @@ -245,8 +248,16 @@ foreach my $method (qw(areacode subscriber)) { } } +sub _is_canadian_600 { + my $self = shift; + ${$self} =~ /^(\+1)?6([0234578])\2/; +} + sub is_geographic { my $self = shift; + # 600 is non-geographic. 6(22|33|44|55|77|88) are reserved + # for non-geographic use but not yet in use + return 0 if($self->_is_canadian_600()); # NANP-globals like 1-800 aren't geographic, the rest are return ref($self) eq __PACKAGE__ ? 0 : 1; } diff --git a/t/inc/common-nanp_and_libphonenumber_tests.pl b/t/inc/common-nanp_and_libphonenumber_tests.pl index 316857e..bef7561 100644 --- a/t/inc/common-nanp_and_libphonenumber_tests.pl +++ b/t/inc/common-nanp_and_libphonenumber_tests.pl @@ -17,6 +17,26 @@ note("Common tests for Number::Phone::NANP and Number::Phone::Lib"); +my $ca_600 = $CLASS->new('+1 600 555 1000'); +isa_ok $ca_600, is_libphonenumber() ? 'Number::Phone::StubCountry::CA' + : 'Number::Phone::NANP::CA'; +is $ca_600->country(), 'CA', "$CLASS->new('+1 600 555 1000')->country()"; +is_deeply( + [sort $ca_600->type()], + [sort('is_valid', is_libphonenumber() ? 'is_ipphone' : ())], + "$CLASS->new('+1 600 555 1000')->type()" +); + +my $ca_604 = $CLASS->new('+1 604 555 1000'); +isa_ok $ca_604, is_libphonenumber() ? 'Number::Phone::StubCountry::CA' + : 'Number::Phone::NANP::CA'; +is $ca_604->country(), 'CA', "$CLASS->new('+1 604 555 1000')->country()"; +is_deeply( + [sort $ca_604->type()], + [sort qw(is_geographic is_valid)], + "$CLASS->new('+1 604 555 1000')->type()" +); + my $the_man = '+1 (202) 456-6213'; my $us = $CLASS->new($the_man); isa_ok $us, is_libphonenumber() ? 'Number::Phone::StubCountry::US'