aboutsummaryrefslogtreecommitdiff
path: root/Makefile.am
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile.am')
0 files changed, 0 insertions, 0 deletions
(tz-lines (filter (lambda (line) (not (eq? (string-ref line 0) #\#))) lines))) (map (lambda (line) (posix-tz->timezone (zonetab-line->posix-tz line))) tz-lines))))) (define (timezones->timezone-tree timezones) "Convert the list of timezones, TIMEZONES into a tree under the form: (\"America\" (\"North_Dakota\" \"New_Salem\" \"Center\")) representing America/North_Dakota/New_Salem and America/North_Dakota/Center timezones." (define (remove-first lists) "Remove the first element of every sublists in the argument LISTS." (map (lambda (list) (if (null? list) list (cdr list))) lists)) (let loop ((cur-timezones timezones)) (match cur-timezones (() '()) (((region . rest-region) . rest-timezones) (if (null? rest-region) (cons (list region) (loop rest-timezones)) (receive (same-region other-region) (partition (lambda (timezone) (string=? (car timezone) region)) cur-timezones) (acons region (loop (remove-first same-region)) (loop other-region)))))))) (define (locate-children tree path) "Return the children of the timezone indicated by PATH in the given TREE. Raise a condition if the PATH could not be found." (let ((extract-proc (cut map car <>))) (match path (() (sort (extract-proc tree) string<?)) ((region . rest) (or (and=> (assoc-ref tree region) (cut locate-children <> rest)) (raise (condition (&message (message (format #f (G_ "Unable to locate path: ~a.") path)))))))))) (define (timezone-has-child? tree timezone) "Return #t if the given TIMEZONE any child in TREE and #f otherwise." (not (null? (locate-children tree timezone)))) (define* (zonetab->timezone-tree zonetab) "Return the timezone tree corresponding to the given ZONETAB file." (timezones->timezone-tree (zonetab->timezones zonetab))) ;;; ;;; Configuration formatter. ;;; (define (posix-tz->configuration timezone) "Return the configuration field for TIMEZONE." `((timezone ,timezone)))