diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 22:50:59 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 22:50:59 +0100 |
commit | 0cce4d9c3ffcadd042182d08c3e569145f321037 (patch) | |
tree | f691593e6dda03f6fac26b11337b6312dc90b95b /module/datetime.scm | |
parent | Actually use X-WR-CALNAME. (diff) | |
download | calp-0cce4d9c3ffcadd042182d08c3e569145f321037.tar.gz calp-0cce4d9c3ffcadd042182d08c3e569145f321037.tar.xz |
Datetime cleanup.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r-- | module/datetime.scm | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/module/datetime.scm b/module/datetime.scm index a127b274..01bbdfa1 100644 --- a/module/datetime.scm +++ b/module/datetime.scm @@ -335,6 +335,11 @@ (define-public (date-zero? date) (= 0 (year date) (month date) (day date))) +;; TODO +1 month is weird for late days in a month. +;; is the last of january +1 month the last of february, +;; or a few days into march? It's at least not the 31 of +;; February, as the code is currently written. +;; (date+ #2020-01-31 #0000-01-00) ; => 2020-02-31 (define (date+%% change base) (define-values (days-fixed change*) @@ -384,12 +389,11 @@ (negative? (day change))) (error "Change can't be negative")) - (when (or (negative? (month base)) - (negative? (day base))) - (error "Base month or day can't be negative")) + (unless (and (< 0 (month base)) + (< 0 (day base))) + (error "Base day and month needs to be at least one" base)) - (date+%% change base) - ) + (date+%% change base)) ;; @var{base} MUST be a valid real date. all rest arguments can however ;; be "invalid" dates, such as 0000-00-10 @@ -448,6 +452,7 @@ ;;; time +;; overflow is number of days above ;; time x time → time x int (define-public (time+% base change) @@ -471,7 +476,6 @@ (minute = (- 60)))) target))) - ;; ahtns auoe htns a oeuhnstaoue nhts aoeu nshtaoeu snht oeuia htns oaeu nsht aoeuö ntshaouentsh oaesnuthg aoeu nsthaoeu nshtaou eshtnnh toaeuhnst oeuhtns (define hour-almost-fixed (set (hour minute-fixed) = (+ (hour change)))) ;; (format #t "~s ~s ~s~%" second-fixed minute-fixed hour-almost-fixed) @@ -532,6 +536,7 @@ ;;; DATETIME + ;; NOTE that base is re-normalized, but change isn't. This is due to base ;; hopefully being a real date, but change just being a difference. (define-public (datetime+ base change) |