calendar.format: Add a word to format time to a string for convenience.
parent
97097fae2c
commit
9b97da0658
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue