From fa3f23105ddcf07c5900de47f19af43d1db1b597 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:27 -0800 Subject: Import Upstream version 2c3 --- timezone.scm | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'timezone.scm') 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) -- cgit v1.2.3