 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays ascii assocs assocs.extras calendar
-calendar.english combinators combinators.smart grouping
-interval-maps io.encodings.utf8 io.files kernel math math.parser
-memoize namespaces sequences sequences.extras sorting splitting
-splitting.extras ;
+calendar.english combinators combinators.short-circuit
+combinators.smart csv grouping interval-maps io.encodings.utf8
+io.files kernel math math.parser memoize namespaces sequences
+sequences.extras sorting splitting splitting.extras ;
+QUALIFIED: sets
 IN: zoneinfo
 
 CONSTANT: zoneinfo-paths

        [ 3 tail harvest ]
    } cleave raw-zone boa ;

: parse-line ( seq -- tuple )
    dup first >lower
    {
        { "rule" [ parse-rule ] }

MEMO: zoneinfo-array ( -- seq )
    zoneinfo-files concat ;

MEMO: zoneinfo-assoc ( -- assoc )
    zoneinfo-paths [ dup parse-zoneinfo-file ] { } map>assoc ;

: raw-rule-map ( -- assoc )
    zoneinfo-array [ raw-rule? ] filter [ name>> ] collect-by ;

: current-rule-map ( -- assoc )
    raw-rule-map
    [ [ to>> "max" = ] filter ] assoc-map
    harvest-values ;

: raw-zone-map ( -- assoc )
    zoneinfo-array [ raw-zone? ] filter [ name>> ] collect-by ;
