diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 23:02:24 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 23:02:24 +0100 |
commit | 6546132ed7b3fdc556912eab7fbc709875cb0b73 (patch) | |
tree | c960b3bc91415814ea744579addd3b0338ef5682 /module/datetime.scm | |
parent | Add comment about DST and create-top-block. (diff) | |
download | calp-6546132ed7b3fdc556912eab7fbc709875cb0b73.tar.gz calp-6546132ed7b3fdc556912eab7fbc709875cb0b73.tar.xz |
Move some datetime procedures to propper modules.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r-- | module/datetime.scm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/module/datetime.scm b/module/datetime.scm index 4a53ed95..aebc7433 100644 --- a/module/datetime.scm +++ b/module/datetime.scm @@ -648,6 +648,28 @@ + +;; @example +;; (time->decimal-hour #10:30:00) ; => 10.5 +;; @end example +(define-public (time->decimal-hour time) + (exact->inexact (+ (hour time) + (/ (minute time) 60) + (/ (second time) 3600)))) + +(define-public (datetime->decimal-hour dt) + (unless (and (zero? (month (get-date dt))) + (zero? (year (get-date dt)))) + (error "Multi-month intervals not yet supported" dt)) + ;; TODO + ;; (date-difference #2020-12-31 #2020-01-01) ; => 0000-11-30 + ;; to get number of days in diff-time we need to count number of days + ;; in each month from start and forward + (+ (time->decimal-hour (get-time% dt)) + (* (day (get-date dt)) 24))) + + + ;;; Parsers for vcomponent usage ;; substring to number, local here |