DrHyde / perl-modules-Number-Phone

Number::Phone and friends
24 stars 31 forks source link

Formatting of UK Mobile Numbers #75

Closed graeme83 closed 6 years ago

graeme83 commented 7 years ago

I am using Number::Phone to validate a user entered telephone number, and then using format to output a correctly formatted version of the number for display. This is working great for landlines, so users entering 999999999 returns "+44 999 9999". But for mobile numbers as they don't have an areacode, the formatting returns the number without gaps.

It would be great if Number::Phone->new('GB', '07530999999'); Returned +44 7530 999999 on format()

Rather than +44 7530999999

This would then be similar to the National or International function of libphonenumber https://giggsey.com/libphonenumber/?phonenumber=07530999999&country=GB&language=&region=

dracos commented 7 years ago

If you are able to use Number::Phone::Lib, you get what you want:

§ perl -e'use v5.14;
use Number::Phone::Lib;
my $n = Number::Phone::Lib->new("+447530999999");
say $n->format;'
+44 7530 999999
DrHyde commented 6 years ago

Fixed in 9975a60, which will be in the next release. That commit should also apply cleanly to 3.4004 if you want it earlier :-)