anchor.diff:  (defpackage org.tymoonnext.colleen.mod.google
     (:use :cl :colleen :events :split-sequence))
   (in-package :org.tymoonnext.colleen.mod.google)
  +
   (eval-when (:compile-toplevel :load-toplevel :execute)
     (ql:quickload :parse-number))
   
  
positive.code: (defvar *unix-epoch-difference* (encode-universal-time 0 0 0 1 1 1970 0))
  (defun get-unix-time ()
    (- (get-universal-time) *unix-epoch-difference*))
  (define-command (google timezone) (latitude longitude &optional timestamp) (:documentation "Retrieve timezone data about a geographical location.")
    (let ((latitude (parse-number:parse-number latitude))
          (longitude (parse-number:parse-number longitude))
          (timestamp (if timestamp (parse-integer timestamp) (get-unix-time))))
      (multiple-value-bind (id name dst raw) (timezone latitude longitude timestamp)
        (respond event "~a, ~a (dst: ~d, raw: ~d)" id name dst raw))))
  
  (defun timezone (latitude longitude &optional (timestamp (get-unix-time)))
    (let ((json (json-request "https://maps.googleapis.com/maps/api/timezone/json"
  
negative.code:         (mapcar #'(lambda (a) (cdr (assoc :elements a))) (cdr (assoc :rows json)))
          (error (cdr (assoc :status json))))))
  
  (defun great-circle-distance (lng1 lat1 lng2 lat2)
    (flet ((rad (x) (/ (* x Pi) 180))
           (haversine (x) (expt (sin (/ x 2)) 2)))
      (let ((earth-radius 6371)
            (lat1 (rad lat1)) (lng1 (rad lng1))
            (lat2 (rad lat2)) (lng2 (rad lng2)))
        (* 2
           earth-radius
           (asin (sqrt (+ (haversine (- lat2 lat1))
                          (* (cos lat1) (cos lat2)
                             (haversine (- lng2 lng1))))))))))
  
  (defun transport-time (distance)
    (flet ((format-and-print (divisor transport-method)
             (format NIL "Human terms: ~,3f hours away by ~a, using an average speed of ~d km/h."
                     (/ distance divisor) transport-method divisor)))
      (cond
        ((< distance 0))
        ((< distance 150)
         (format-and-print 50 "car"))
        ((< distance 2500)
         (format-and-print 130 "train"))
        ((< distance 12500)
         (format-and-print 800 "plane"))
        (T
         (format-and-print 18000 "ICBM")))))
  
  (defun estimated-distance (origin destination)
    (multiple-value-bind (from-latitude from-longitude) (coordinates origin)
      (multiple-value-bind (to-latitude to-longitude) (coordinates destination)
        (let ((distance (great-circle-distance from-longitude from-latitude to-longitude to-latitude)))
          (format NIL "Distance: ~,2f km, ~a" distance
                  (transport-time distance))))))
  