 
 MEMO: zoneinfo-files ( -- seq )
     zoneinfo-paths [ parse-zoneinfo-file ] map ;
+
+MEMO: zoneinfo-array ( -- seq )
+    zoneinfo-files concat ;
+
+
+: raw-rule-map ( -- assoc )
+    zoneinfo-array [ raw-rule? ] filter [ name>> ] collect-by ;
+
+: raw-zone-map ( -- assoc )
+    zoneinfo-array [ raw-zone? ] filter [ name>> ] collect-by ;
     
 GENERIC: zone-matches? ( string rule -- ? )
 

! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators combinators.smart io.encodings.utf8 io.files
kernel namespaces sequences splitting unicode.case accessors
math.parser calendar memoize fry ;
IN: zoneinfo

CONSTANT: zoneinfo-paths

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

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

ERROR: zone-not-found name ;

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

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

! "Europe/Helsinki" find-zone-rules

! Rule
! name - string
