 
 ;EBNF
 
-PRIVATE>
-
-MACRO: printf ( format-string -- )
+: printf-quot ( format-string -- format-quot n )
     parse-printf [ [ callable? ] count ] keep [
         dup string? [ 1quotation ] [ [ 1 - ] dip ] if
         over [ ndip ] 2curry
-    ] map nip [ compose-all ] [ length ] bi '[
+    ] map nip [ compose-all ] [ length ] bi ; inline
+
+PRIVATE>
+
+MACRO: printf ( format-string -- )
+    printf-quot '[
         @ output-stream get [ stream-write ] curry _ napply
     ] ;
 
-: sprintf ( format-string -- result )
-    [ printf ] with-string-writer ; inline
+MACRO: sprintf ( format-string -- result )
+    printf-quot '[
+        @ _ "" nappend-as
+    ] ;
 
 : vprintf ( seq format-string -- )
     parse-printf output-stream get '[

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

