Learn R Programming

r2country (version 2.0.2.4.0)

timeIn: Fetch the current time in a specific city

Description

Get the current time using specified city name

Usage

timeIn

Arguments

Value

a list containing all cities and corresponding local time

Format

An object of class list of length 2226.

Examples

Run this code
# view the searchable cities, return first 10
names(timeIn)[1:10]

#task 0: check if the time in Delhi is present
#should be all in lower case
grep("delhi",names(timeIn), value = TRUE)

#task 1: check the time in delhi
timeIn$`india, delhi, new delhi`

#task 2: check the time in Boston
timeIn$`usa, massachusetts, boston`

#task 3: view the time in multiple countries
timeIn[c(
"china, zhejiang, hangzhou",
"nigeria, kano, kano",
"usa, texas, garland"
)]

#task 4: what if the city is not available
timeIn[c("randomcity","york","jerusalem")]

Run the code above in your browser using DataLab