]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar.format: Add a word to format time to a string for convenience.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 9 Jul 2018 03:57:24 +0000 (22:57 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 9 Jul 2018 03:57:24 +0000 (22:57 -0500)
basis/calendar/format/format.factor

index 1c4c685248c9c533ef27cb7baa6c27de1d80b529..853bd32c2cc77c02c16af2d6eb47c7b555a9bb77 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays calendar calendar.english combinators io
-io.streams.string kernel macros math math.order math.parser
-math.parser.private present quotations sequences typed words ;
+USING: accessors arrays calendar calendar.english combinators
+fry io io.streams.string kernel macros math math.order
+math.parser math.parser.private present quotations sequences
+typed words ;
 IN: calendar.format
 
 MACRO: formatted ( spec -- quot )
@@ -14,6 +15,9 @@ MACRO: formatted ( spec -- quot )
         } cond
     ] map [ cleave ] curry ;
 
+: formatted>string ( spec -- string )
+    '[ _ formatted ] with-string-writer ; inline
+
 : pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ;
 
 : pad-0000 ( n -- str ) number>string 4 CHAR: 0 pad-head ;