Skip to contents

Get the current time using specified city name

Usage

timeIn

Format

An object of class list of length 2226.

Value

a list containing all cities and corresponding local time

Examples

# view the searchable cities, return first 10
names(timeIn)[1:10]
#>  [1] "afghanistan, kabul"                               
#>  [2] "albania, tirana"                                  
#>  [3] "algeria, algiers"                                 
#>  [4] "andorra, andorra la vella"                        
#>  [5] "angola, luanda"                                   
#>  [6] "antigua and barbuda, saint john's"                
#>  [7] "argentina, buenos aires"                          
#>  [8] "armenia, yerevan"                                 
#>  [9] "aruba, aruba, oranjestad"                         
#> [10] "australia, australian capital territory, canberra"

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

#task 1: check the time in delhi
timeIn$`india, delhi, new delhi`
#> $as.is
#> [1] "2023-12-11 07:32:51 EST"
#> 
#> $dst.adj
#> [1] "2023-12-11 07:32:51 EST"
#> 

#task 2: check the time in Boston
timeIn$`usa, massachusetts, boston`
#> $as.is
#> [1] "2023-12-10 22:06:52 EST"
#> 
#> $dst.adj
#> [1] "2023-12-10 22:06:52 EST"
#> 

#task 3: view the time in multiple countries
timeIn[c(
"china, zhejiang, hangzhou",
"nigeria, kano, kano",
"usa, texas, garland"
)]
#> $`china, zhejiang, hangzhou`
#> $`china, zhejiang, hangzhou`$as.is
#> [1] "2023-12-11 10:05:51 EST"
#> 
#> $`china, zhejiang, hangzhou`$dst.adj
#> [1] "2023-12-11 10:05:51 EST"
#> 
#> 
#> $`nigeria, kano, kano`
#> $`nigeria, kano, kano`$as.is
#> [1] "2023-12-11 03:05:52 EST"
#> 
#> $`nigeria, kano, kano`$dst.adj
#> [1] "2023-12-11 03:05:52 EST"
#> 
#> 
#> $`usa, texas, garland`
#> $`usa, texas, garland`$as.is
#> [1] "2023-12-10 21:06:52 EST"
#> 
#> $`usa, texas, garland`$dst.adj
#> [1] "2023-12-10 21:06:52 EST"
#> 
#> 

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