diff options
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) | 
