"vocab:zoneinfo/pacificnew"
"vocab:zoneinfo/southamerica"
"vocab:zoneinfo/backzone"
+ "vocab:zoneinfo/etcetera"
}
CONSTANT: zoneinfo-extra-paths
{
"vocab:zoneinfo/backward"
- "vocab:zoneinfo/etcetera"
"vocab:zoneinfo/factory"
"vocab:zoneinfo/leapseconds"
"vocab:zoneinfo/systemv"
: zoneinfo-lines ( path -- seq )
utf8 file-lines
- [ { [ length 0 = ] [ "#" head? ] } 1|| ] reject ;
+ [ { [ length 0 = ] [ "#" head? ] } 1|| ] reject
+ [ "#" split1-last drop ] map ;
TUPLE: zonetab codes lat lng tz comments ;
C: <zonetab> zonetab
: lookup-country-names ( seq -- seq' ) [ lookup-country-name ] map ;
: timezone>country-map ( -- alist )
- parse-zonetabs [ second ] collect-key-by ;
+ parse-zonetabs [ nip ] collect-key-by ;
: country>timezones-map ( -- alist )
- parse-zonetabs [ first ] collect-value-by ;
+ parse-zonetabs [ drop ] collect-value-by ;
: country-timezones-map ( -- alist )
country>timezones-map [ dup lookup-country-names zip ] map-values ;
: zoneinfo-zones ( -- seq )
raw-zone-map keys
- [ "/" swap subseq? ] partition
+ [ "/" subseq-index? ] partition
[ natural-sort ] bi@ append ;
GENERIC: zone-matches? ( string rule -- ? )
: comparison-day-string ( timestamp string -- timestamp )
{
- { [ ">=" over subseq? ] [ ">=" split1 swap [ string>number >>day ] dip day-abbrev>= ] }
- { [ "<=" over subseq? ] [ "<=" split1 swap [ string>number >>day ] dip day-abbrev<= ] }
+ { [ dup ">=" subseq-index? ] [ ">=" split1 swap [ string>number >>day ] dip day-abbrev>= ] }
+ { [ dup "<=" subseq-index? ] [ "<=" split1 swap [ string>number >>day ] dip day-abbrev<= ] }
[ string>number >>day ]
} cond ;
":" split1 "0" or [ string>number ] bi@
[ instant ] 2dip 0 set-time ;
+: hms>duration ( str -- duration )
+ ":" split 3 "0" pad-tail
+ [ string>number ] map first3
+ [ instant ] 3dip set-time ;
+
: rule>timestamp-rest ( timestamp zone -- from )
{
[ over fp-infinity? [ drop ] [ in>> month-abbreviation-index >>month ] if ]
raw-rule-map at [
[
[ rule>timestamps [ dup fp-infinity? [ timestamp>unix-time ] unless ] bi@ 2array ]
- [ [ save>> hm>duration ] [ letters>> ] bi 2array ] bi 2array
+ [ [ save>> hms>duration ] [ letters>> ] bi 2array ] bi 2array
] map
] keep zip ;