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