From 9b97da06580505c1fcccd3378f3d2da4a75f8c2d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 8 Jul 2018 22:57:24 -0500 Subject: [PATCH] calendar.format: Add a word to format time to a string for convenience. --- basis/calendar/format/format.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/basis/calendar/format/format.factor b/basis/calendar/format/format.factor index 1c4c685248..853bd32c2c 100644 --- a/basis/calendar/format/format.factor +++ b/basis/calendar/format/format.factor @@ -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 ;