aboutsummaryrefslogtreecommitdiff
path: root/module/datetime.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-24 22:50:59 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-24 22:50:59 +0100
commit0cce4d9c3ffcadd042182d08c3e569145f321037 (patch)
treef691593e6dda03f6fac26b11337b6312dc90b95b /module/datetime.scm
parentActually use X-WR-CALNAME. (diff)
downloadcalp-0cce4d9c3ffcadd042182d08c3e569145f321037.tar.gz
calp-0cce4d9c3ffcadd042182d08c3e569145f321037.tar.xz
Datetime cleanup.
Diffstat (limited to 'module/datetime.scm')
-rw-r--r--module/datetime.scm17
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)