get_timezone: Phone number time zone

Description Usage Arguments Details Value libphonenumber reference Examples

View source: R/timezone.R

Description

Retrieve a list of CLDR time zones to which a phone number belongs.

Usage

1
get_timezone(x, strict = FALSE)

Arguments

x

A phone vector.

strict

Should invalid phone numbers be removed? If TRUE, invalid phone numbers are replaced with NA.

Details

This function assumes the phone number is geo-localizable. Fixed-line and mobile numbers are considered possible candidates for geo-localization.

Value

A character vector of time zones to which each phone number belongs, separated by ;, or the default unknown time zone "Etc/Unknown" if no other time zone was found.

libphonenumber reference

get_timezone(): PhoneNumberToTimeZonesMapper.getTimeZonesForGeographicalNumber().

Examples

1
2
3
4
5
6
x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")
get_timezone(x)
get_timezone(x, strict = TRUE)

# Return a list
strsplit(get_timezone(x), ";")

Example output

sh: 1: cannot create /dev/null: Permission denied
OpenJDK 64-Bit Server VM warning: Can't detect primordial thread stack location - find_vma failed
[1] NA                 "Australia/Sydney" "Australia/Sydney" "Australia/Sydney"
[5] "Australia/Sydney" "America/New_York"
[1] NA                 NA                 "Australia/Sydney" "Australia/Sydney"
[5] "Australia/Sydney" "America/New_York"
[[1]]
[1] NA

[[2]]
[1] "Australia/Sydney"

[[3]]
[1] "Australia/Sydney"

[[4]]
[1] "Australia/Sydney"

[[5]]
[1] "Australia/Sydney"

[[6]]
[1] "America/New_York"

dialr documentation built on May 24, 2021, 5:07 p.m.