Skip to content

Rust SDK

Install

# Cargo.toml
[dependencies]
timenow = "1.0"
cargo add timenow

Quick Start

use timenow::TimeNowClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = TimeNowClient::new("http://localhost:8090");

    // Solar time for London
    let result = client.get_solar_time(51.5074, -0.1278, None).await?;
    println!("{}", result.solar_time);            // "2026-04-14T11:49:23"
    println!("{}", result.civil_solar_offset_min); // -10.6

    // Social jetlag
    let jetlag = client.get_jetlag(39.47, 75.99).await?;
    println!("{}", jetlag.risk_level); // "severe"

    Ok(())
}

Methods

Method Signature Returns API endpoint
get_solar_time (lat: f64, lng: f64, utc: Option<&str>) Result<SolarTimeResult> GET /solar
get_jetlag (lat: f64, lng: f64) Result<JetlagResult> GET /solar/jetlag
get_prayer_times (lat: f64, lng: f64, date: Option<&str>, convention: Option<&str>) Result<PrayerTimesResult> GET /solar/prayer
get_almanac (lat: f64, lng: f64, year: Option<i32>) Result<AlmanacResult> GET /solar/almanac
health () Result<bool> GET /health

Types

#[derive(Debug, Deserialize)]
pub struct SolarTimeResult {
    pub latitude: f64,
    pub longitude: f64,
    pub utc: String,
    pub solar_time: String,
    pub civil_time: String,
    pub equation_of_time_min: f64,
    pub civil_solar_offset_min: f64,
    pub timezone: String,
    pub solar_noon_utc: String,
    pub sunrise_utc: String,
    pub sunset_utc: String,
}