aboutsummaryrefslogtreecommitdiff
path: root/module/srfi
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-11-08 20:32:54 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-11-08 20:32:54 +0100
commitbb2b57e7bfc8f649283737fc0e8b18320ab0b3b7 (patch)
treecd1db5f1d9ba23e4b2a89d84257acf3d3069bfca /module/srfi
parentDocumentation in parse. (diff)
downloadcalp-bb2b57e7bfc8f649283737fc0e8b18320ab0b3b7.tar.gz
calp-bb2b57e7bfc8f649283737fc0e8b18320ab0b3b7.tar.xz
Fix leap-seconds in normalize-date*.
Diffstat (limited to 'module/srfi')
-rw-r--r--module/srfi/srfi-19/util.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/module/srfi/srfi-19/util.scm b/module/srfi/srfi-19/util.scm
index 4155b263..ff23dbb9 100644
--- a/module/srfi/srfi-19/util.scm
+++ b/module/srfi/srfi-19/util.scm
@@ -98,11 +98,21 @@ attribute set to 0. Can also be seen as \"Start of day\""
(time<? s1-end s2-end))))
(define-public (normalize-date date)
+
(time-utc->date (date->time-utc date)
(zone-offset date)))
-(define-public normalize-date*
- (compose time-utc->date date->time-utc))
+;; Normalize a date on a weird form back into a propper form,
+;; for example, 2019-11-32 becomes 2019-12-02.
+;; The whole adding 10 seconds and then removing them is a dirty
+;; hack to handle leap seconds. NOTE this should be reworked.
+(define-public (normalize-date* date)
+ (define next-date
+ (date-second
+ (time-utc->date
+ (add-duration (date->time-utc date)
+ (make-time time-duration 0 10)))
+ (set next-date 0))))
;; Returns a stream of date objects, one day appart, staring from start-day.
(define-public (day-stream start-day)