         } spread timestamp>unix-time
     ] if-empty ;
 
-: zones>interval-map ( zones -- interval-map )
+: raw-zones>interval-map ( raw-zones -- interval-map )
     [
         [ until>> until>timestamp ] map
         -1/0. prefix 2 <clumps> [ >array ] map
     ] keep zip
     [ first2 1 - 2array ] map-keys <interval-map> ;
 
-: name>zones ( name -- interval-map )
-    raw-zone-map at zones>interval-map ;
-
-: gmt-offset ( timestamp name -- gmt-offset )
+: timezone>interval-map ( timezone-name -- interval-map )
+    raw-zone-map at raw-zones>interval-map ;
+
+: gmt-offset ( timestamp timezone-name -- gmt-offset )
     [ timestamp>unix-time ]
-    [ zones>interval-map ] bi* interval-at ;
+    [ raw-zones>interval-map ] bi* interval-at ;
 
 : name>rules ( name -- rules )
     raw-rule-map at [


: zoneinfo-lines ( path -- seq )
    utf8 file-lines
    [
        { [ length 0 = ] [ "#" head? ] } 1||
    ] reject ;

TUPLE: zonetab codes lat lng tz comments ;
C: <zonetab> zonetab
MEMO: zoneinfo-country-zones ( -- seq )
    "vocab:zoneinfo/zone1970.tab" zoneinfo-lines
    [

        [ 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 ;
