R SDK
Install
install.packages("timenow")
# or from GitHub:
remotes::install_github("koke1997/timenow", subdir = "sdk/r")
Quick Start
library(timenow)
client <- TimeNowClient$new("http://localhost:8090")
# Solar time for London
result <- client$get_solar_time(lat = 51.5074, lng = -0.1278)
print(result$solar_time) # "2026-04-14T11:49:23"
print(result$civil_solar_offset_min) # -10.6
# Social jetlag
jetlag <- client$get_jetlag(lat = 39.47, lng = 75.99)
print(jetlag$risk_level) # "severe"
# Deviation map as data frame
df <- client$get_deviation_map(format = "csv")
hist(df$civil_solar_offset_min, main = "Global Civil-Solar Offset Distribution")
Methods
| Method | Parameters | Returns | API endpoint |
get_solar_time(lat, lng, utc) | numeric, numeric, optional string | list | GET /solar |
get_jetlag(lat, lng) | numeric, numeric | list | GET /solar/jetlag |
get_prayer_times(lat, lng, date, convention) | numeric × 2, optional strings | list | GET /solar/prayer |
get_almanac(lat, lng, year) | numeric × 2, optional int | list | GET /solar/almanac |
get_deviation_map(format) | "json", "csv", or "geojson" | list or data.frame | GET /world/deviation-map |
health() | — | logical | GET /health |
Research Example
library(timenow)
library(ggplot2)
client <- TimeNowClient$new("http://localhost:8090")
df <- client$get_deviation_map(format = "csv")
ggplot(df, aes(x = lng, y = lat, fill = civil_solar_offset_min)) +
geom_tile() +
scale_fill_gradient2(low = "blue", mid = "white", high = "red",
midpoint = 0, name = "Civil-Solar\nOffset (min)") +
labs(title = "Global Civil-Solar Time Misalignment") +
theme_minimal()