 USING: accessors arrays assocs calendar combinators
 combinators.smart fry generalizations io io.streams.string
 kernel macros math math.functions math.parser namespaces
-peg.ebnf present prettyprint quotations sequences strings
-unicode.case unicode.categories vectors ;
+peg.ebnf present prettyprint quotations sequences
+sequences.generalizations strings unicode.case
+unicode.categories vectors ;
 FROM: math.parser.private => format-float ;
 IN: formatting
 

       } cleave
    ] output>array " " join ; inline

: (week-of-year) ( timestamp day -- n )
    [ dup clone 1 >>month 1 >>day day-of-week dup ] dip > [ 7 swap - ] when
    [ day-of-year ] dip 2dup < [ 0 2nip ] [ - 7 / 1 + >fixnum ] if ;

: week-of-year-sunday ( timestamp -- n ) 0 (week-of-year) ; inline

: week-of-year-monday ( timestamp -- n ) 1 (week-of-year) ; inline

EBNF: parse-strftime



<PRIVATE

: pad-00 ( n -- string )
    number>string 2 CHAR: 0 pad-head ; inline

: pad-000 ( n -- string )
    number>string 3 CHAR: 0 pad-head ; inline

: >time ( timestamp -- string )
    [ hour>> ] [ minute>> ] [ second>> floor ] tri
    [ pad-00 ] tri@ 3array ":" join ; inline

: >date ( timestamp -- string )
    [ month>> ] [ day>> ] [ year>> ] tri
    [ pad-00 ] tri@ 3array "/" join ; inline

: >datetime ( timestamp -- string )
    [
