diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:27 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:27 -0800 |
commit | fa3f23105ddcf07c5900de47f19af43d1db1b597 (patch) | |
tree | b2c6cce6b97698098f50cbc78c23fdc0f8d401ab /timezone.scm | |
parent | f24b9140d6f74804d5599ec225717d38ca443813 (diff) | |
download | slib-142a472fc4601d12b5913528ed42260464f65acf.tar.gz slib-142a472fc4601d12b5913528ed42260464f65acf.zip |
Import Upstream version 2c3upstream/2c3
Diffstat (limited to 'timezone.scm')
-rw-r--r-- | timezone.scm | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/timezone.scm b/timezone.scm index 8daa8fb..2890c39 100644 --- a/timezone.scm +++ b/timezone.scm @@ -57,6 +57,25 @@ (define tz:default #f) +;;; This definition is here so that READ-TZFILE can verify the +;;; existence of these files before loading tzfile.scm to actually +;;; read them. +(define tzfile:vicinity (make-vicinity "/usr/lib/zoneinfo/")) + +(define (read-tzfile path) + (let ((realpath + (cond ((not path) (in-vicinity tzfile:vicinity "localtime")) + ((or (char-alphabetic? (string-ref path 0)) + (char-numeric? (string-ref path 0))) + (in-vicinity tzfile:vicinity path)) + (else path)))) + (and (file-exists? realpath) + (let ((zone #f)) + (require 'tzfile) + (set! zone (tzfile:read realpath)) + (if zone (list->vector (cons 'tz:file zone)) + (slib:error 'read-tzfile realpath)))))) + ;;; Parse Posix TZ string. (define (string->transition-day-time str) @@ -125,21 +144,6 @@ (vector 'tz:rule tz tzname dtzname offset doffset start end)))) (else #f)))) -(define (read-tzfile path) - (require 'tzfile) - (let ((realpath - (cond ((not path) (in-vicinity tzfile:vicinity "localtime")) - ((or (char-alphabetic? (string-ref path 0)) - (char-numeric? (string-ref path 0))) - (in-vicinity tzfile:vicinity path)) - (else path)))) - (if (file-exists? realpath) - (let ((zone (tzfile:read realpath))) - (if zone (list->vector (cons 'tz:file zone)) - (slib:error 'read-tzfile realpath))) - (slib:error 'read-tzfile "file not found:" realpath) - ))) - (define (time-zone tz) (cond ((not tz) (read-tzfile #f)) ((vector? tz) tz) |