fork download
  1. (defun clock (hhmm)
  2. (let ((hh (parse-integer (subseq hhmm 0 2)))
  3. (mm (parse-integer (subseq hhmm 3 5))))
  4. (princ
  5. (substitute #\ #\- (format nil
  6. "It's ~r~:[~:[~; oh~] ~r~;~*~*~] ~:[pm~;am~]~%"
  7. (1+ (mod (1- hh) 12))
  8. (= mm 0)
  9. (< mm 10)
  10. mm
  11. (< hh 12))))))
  12.  
  13. ;; test
  14. (mapc #'clock '("00:00" "01:30" "12:05" "14:01" "20:29" "21:00"))
Success #stdin #stdout 0s 203840KB
stdin
Standard input is empty
stdout
It's twelve am
It's one thirty am
It's twelve oh five pm
It's two oh one pm
It's eight twenty nine pm
It's nine pm