I need to perform calculations with a symbol. I need to convert the time which is of hh:mm form to the minutes passed.
;; (get-minutes symbol)->number
;; convert the time in hh:mm to minutes
;; (get-minutes 6:19)-> 6* 60 + 19
(define (get-minutes time)
(let* ((a-time (string->list (symbol->string time)))
(hour (first a-time))
(minutes (third a-time)))
(+ (* hour 60) minutes)))
This is an incorrect code, I get a character after all that conversion and cannot perform a correct calculation.
Do you guys have any suggestions? I cant change the input type.
Context: The input is a flight schedule so I cannot alter the data structure.
;; ----------------------------------------------------------------------
Edit: Figured out an ugly solution. Please suggest something better.
(define (get-minutes time)
(let* ((a-time (symbol->string time))
(hour (string->number (substring a-time 0 1)))
(minutes (string->number (substring a-time 2 4))))
(+ (* hour 60) minutes)))