-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathECU.coffee
45 lines (38 loc) · 1.2 KB
/
ECU.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Ecuador
# http://www.howtocallabroad.com/ecuador/
class Ecuador
constructor: ->
@countryName = "Ecuador"
@countryNameAbbr = "ECU"
@countryCode = '593'
@regex = /^(?:(?:(?:\+|)593)|)(?:0|)(?:(?:(?:[234567])\d{7})|(?:9\d{8}))$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode =
[
'2', '3', '4', '5', '6', '7', '9'
]
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if withoutNDC.length is 7 and ndc isnt '9'
return phone
else if ndc is '9'and withoutNDC.length is 8
phone.isMobile = true
phone.number = withoutCountryCode
phone.nationalDestinationCode = ''
return phone
splitNumber: (number) =>
if number.length is 7
return Phone.compact number.split(/(\d{3})(\d{4})/)
else if number.length is 9
if number.indexOf("9") is 0
return Phone.compact number.split(/(\d{2})(\d{3})(\d{4})/)
return [number]
# register
ecuador = new Ecuador()
Phone.countries['593'] = ecuador
# exports
module.exports = ecuador