Skip to content

Common Lisp SDK

Install

;; Via Quicklisp (after cloning into local-projects)
(ql:quickload :timenow)

;; Or via ASDF
(asdf:load-system :timenow)

Dependencies: dexador, cl-json, alexandria.

Quick Start

(ql:quickload :timenow)

(defvar *client* (timenow:make-client "http://localhost:8090"))

;; Solar time for London
(let ((result (timenow:get-solar *client* 51.5074 -0.1278)))
  (format t "Solar time: ~a~%" (cdr (assoc :solar--time result)))
  (format t "Offset: ~a min~%" (cdr (assoc :civil--solar--offset--min result))))

;; Social jetlag
(let ((jetlag (timenow:get-jetlag *client* 39.47 75.99)))
  (format t "Risk: ~a~%" (cdr (assoc :risk--level jetlag))))

;; Health check
(timenow:get-health *client*)

Functions

Function Parameters Returns API endpoint
make-client &optional base-url client struct
get-solar client lat lng &key dt alist GET /solar
get-jetlag client lat lng alist GET /solar/jetlag
get-prayer client lat lng &key date alist GET /solar/prayer
get-almanac client lat lng &key year alist GET /solar/almanac
get-reform client lat lng alist GET /solar/reform
get-health client alist GET /health
get-deviation-map client &key format alist GET /world/deviation-map

Types

(defstruct client
  (base-url "http://localhost:8090" :type string))

All API methods return parsed JSON as association lists (alists).

Error Handling

Errors from dexador (HTTP) and cl-json (parsing) propagate as standard Common Lisp conditions:

(handler-case
    (timenow:get-solar *client* 999 0)
  (error (e)
    (format t "Error: ~a~%" e)))