aboutsummaryrefslogtreecommitdiff
path: root/module/datetime
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-17 10:17:33 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-17 10:17:33 +0200
commitf7e489178120813a4aff0eff0140661bf402cbae (patch)
treec55d3ec6ee869a29dd892c8573734df6e18236f6 /module/datetime
parentSetup directories for dist. (diff)
downloadcalp-f7e489178120813a4aff0eff0140661bf402cbae.tar.gz
calp-f7e489178120813a4aff0eff0140661bf402cbae.tar.xz
Work on paths?
Diffstat (limited to 'module/datetime')
-rw-r--r--module/datetime/instance.scm41
1 files changed, 19 insertions, 22 deletions
diff --git a/module/datetime/instance.scm b/module/datetime/instance.scm
index 829002b9..db24d8a2 100644
--- a/module/datetime/instance.scm
+++ b/module/datetime/instance.scm
@@ -1,35 +1,32 @@
(define-module (datetime instance)
:use-module (util)
:use-module (util config)
+ :use-module (util exceptions)
:use-module (datetime zic)
+ :use-module (directories)
:export (zoneinfo))
-(define-config tz-dir #f
- description: "Directory in which zoneinfo files can be found")
-
(define-config tz-list '()
description: "List of default zoneinfo files to be parsed")
-
-(define / file-name-separator-string)
-
;; TODO see (vcomponent instance), this has a similar problem with early load
(define-once zoneinfo
(let ((cache (make-hash-table)))
(label self
- (case-lambda
- (()
- (define tz-dir (get-config 'tz-dir))
- (define tz-list (get-config 'tz-list))
- (when (or (not tz-dir) (null? tz-list))
- (error "Default zoneinfo only available when tz-dir and tz-list are configured"))
- (self tz-dir tz-list))
- ((directory file-list)
- (let ((key (cons directory file-list)))
- (aif (hash-ref cache key)
- it
- (let ((tz (read-zoneinfo
- (map (lambda (s) (string-append directory / s))
- file-list))))
- (hash-set! cache key tz)
- tz))))))))
+ (case-lambda
+ (()
+ (define tz-list (get-config 'tz-list))
+ (if (null? tz-list)
+ (warning "Default zoneinfo only available when tz-dir and tz-list are configured")
+ (self tz-list)))
+ ((file-list)
+ (provide 'zoneinfo)
+ (let* ((directory (path-append data-directory "/zoneinfo"))
+ (key (cons directory file-list)))
+ (aif (hash-ref cache key)
+ it
+ (let ((tz (read-zoneinfo
+ (map (lambda (s) (path-append directory s))
+ file-list))))
+ (hash-set! cache key tz)
+ tz))))))))