D SDK
Install
dub.json dependency:
Quick Start
import timenow.client;
import std.stdio;
void main() {
auto client = new TimeNowClient("http://localhost:8090");
// Solar time for London
auto solar = client.getSolar(51.5074, -0.1278);
writeln("Solar time: ", solar["local_solar_time"].str);
writeln("Offset: ", solar["civil_solar_offset_min"].floating);
// Social jetlag
auto jetlag = client.getJetlag(39.47, 75.99);
writeln("Risk: ", jetlag["risk_level"].str);
// Health check
auto health = client.getHealth();
writeln("Status: ", health["status"].str);
}
Methods
| Method | Signature | Returns | API endpoint |
|---|---|---|---|
getSolar | (double lat, double lng, string dt = null) | JSONValue | GET /solar |
getJetlag | (double lat, double lng) | JSONValue | GET /solar/jetlag |
getPrayer | (double lat, double lng, string date = null) | JSONValue | GET /solar/prayer |
getAlmanac | (double lat, double lng, int year = 0) | JSONValue | GET /solar/almanac |
getReform | (double lat, double lng) | JSONValue | GET /solar/reform |
getTimetable | (double lat1, lng1, lat2, lng2, string departUtc) | JSONValue | GET /solar/timetable |
getDeviationMap | (string fmt = "json") | string | GET /world/deviation-map |
getHealth | () | JSONValue | GET /health |
Types
Model structs are available in timenow.models:
struct SolarResult {
double lat, lng;
string localSolarTime, solarNoon, sunrise, sunset;
double solarElevationDeg, civilSolarOffsetMin;
}
struct JetlagResult {
string riskLevel, equivalentFlight, verdict;
double civilSolarOffsetMin, weeklySleepLossMin, annualSleepLossH;
}
Error Handling
Uses standard D exceptions from std.net.curl: