Tcl SDK
Install
No external dependencies — uses Tcl's built-in http and json packages.
Quick Start
package require timenow
::timenow::init "http://localhost:8090"
# Solar time for London
set solar [::timenow::solar 51.5 -0.1278]
puts "Solar time: [dict get $solar local_solar_time]"
puts "Offset: [dict get $solar civil_solar_offset_min] min"
# Social jetlag
set jetlag [::timenow::jetlag 39.47 75.99]
puts "Risk: [dict get $jetlag risk_level]"
# Health check
set health [::timenow::health]
puts "Status: [dict get $health status]"
Procedures
| Procedure | Parameters | Returns | API endpoint |
|---|---|---|---|
::timenow::init | ?url? | — | — |
::timenow::solar | lat lng ?dt? | dict | GET /solar |
::timenow::jetlag | lat lng | dict | GET /solar/jetlag |
::timenow::prayer | lat lng ?date? | dict | GET /solar/prayer |
::timenow::almanac | lat lng ?year? | dict | GET /solar/almanac |
::timenow::reform | lat lng | dict | GET /solar/reform |
::timenow::deviation_map | ?format? | dict | GET /world/deviation-map |
::timenow::health | — | dict | GET /health |
Configuration
# Default base URL
::timenow::init
# => uses http://localhost:8090
# Custom URL
::timenow::init "http://my-server:8090"
The init procedure sets the ::timenow::baseUrl namespace variable.
Error Handling
API errors raise Tcl errors with HTTP status and response body:
Errors from non-2xx responses: "TimeNow API error <code>: <body>".