         ] map
     ] keep zip ;
 
-: chicago-zones ( -- interval-map ) "America/Chicago" name>zones ;
+: chicago-zones ( -- interval-map ) "America/Chicago" timezone>interval-map ;
 : us-rules ( -- rules ) "US" name>rules ;
-
 : us-timezones ( -- timezones )
     country>timezones-map "US" of ;
 
 : puerto-rico-timezone-countries ( -- countries )
-    timezone>country-map "America/Puerto_Rico" of ;
+    timezone>country-map "America/Puerto_Rico" of lookup-country-names ;

M: raw-leap zone-matches? 2drop f ;
M: raw-zone zone-matches? name>> = ;

: find-rules ( string -- rules )
    raw-rule-map
    [ [ to>> "max" = ] filter ] assoc-map at ;

ERROR: zone-not-found name ;

: find-zone ( string -- zone )
    raw-zone-map
    [ last ] assoc-map ?at [ zone-not-found ] unless ;

: find-zone-rules ( string -- zone rules )
    find-zone dup rules/save>> find-rules ;

: zone-abbrevs ( -- assoc )

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

: parse-rest-of-zone ( prev seq -- zone )
    [ name>> ] dip {
        [ first ]
        [ second ]
        [ 2 swap nth ]
        [ 3 tail harvest ]
    } cleave raw-zone boa ;

: parse-zoneinfo-line ( prev/f seq -- tuple )
    dup first >lower
    {
        { "rule" [ nip parse-rule ] }
        { "link" [ nip parse-link ] }
        { "leap" [ nip parse-leap ] }
        { "zone" [ nip parse-zone ] }
        [ drop harvest parse-rest-of-zone ]
    } case ;

: parse-zoneinfo-file ( path -- seq )
    zoneinfo-lines
    [ "\t " split harvest ] map harvest
    [ parse-zoneinfo-line ] map-with-previous ;

MEMO: zoneinfo-files ( -- seq )
    zoneinfo-paths [ parse-zoneinfo-file ] map ;
