2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! Copyright (C) 2008 John Benediktsson
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! See http://factorcode.org/license.txt for BSD license
							 | 
						
					
						
							
								
									
										
										
										
											2017-01-03 09:48:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								USING: accessors arrays assocs calendar calendar.english combinators
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								combinators.smart fry generalizations io io.streams.string
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								kernel macros math math.functions math.parser namespaces
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								peg.ebnf present prettyprint quotations sequences
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-24 11:01:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								sequences.generalizations strings unicode vectors
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 23:23:57 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								math.functions.integer-logs splitting multiline ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-14 00:24:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								FROM: math.parser.private => format-float ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								IN: formatting
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-18 11:53:29 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								ERROR: unknown-format-directive value ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								<PRIVATE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: compose-all ( seq -- quot )
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-20 12:40:30 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ ] [ compose ] reduce ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: fix-sign ( string -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-30 22:26:23 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dup first CHAR: 0 = [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        dup [ [ CHAR: 0 = not ] [ digit? ] bi and ] find
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            1 - swap 2dup nth {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                { CHAR: - [ remove-nth "-" prepend ] }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                { CHAR: + [ remove-nth "+" prepend ] }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                [ drop nip ]
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-23 03:19:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            } case
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-30 22:26:23 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ] [ drop ] if
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] when ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-23 03:19:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: >digits ( string -- digits )
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ 0 ] [ string>number ] if-empty ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-24 11:01:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: format-decimal-simple ( x digits -- string )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ abs ] dip
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ 10^ * round-to-even >integer number>string ]
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-26 10:55:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        [ 1 + CHAR: 0 pad-head ]
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-09 14:26:39 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        [ cut* ] tri [ "." glue ] unless-empty
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-19 20:15:05 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] keepd neg? [ CHAR: - prefix ] when ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-14 00:24:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-09 14:29:11 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: format-scientific-mantissa ( x log10x digits -- string rounded-up? )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ swap - 10^ * round-to-even >integer number>string ] keep
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    over length 1 - < [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ but-last >string ] when ! 9.9 rounded to 1e+01
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        1 cut [ "." glue ] unless-empty
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] keep ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-14 00:24:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-09 14:29:11 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: format-scientific-exponent ( rounded-up? log10x -- string )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    swap [ 1 + ] when number>string 2 CHAR: 0 pad-head
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-24 11:01:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dup CHAR: - swap index "e" "e+" ? prepend ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: format-scientific-simple ( x digits -- string )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ abs dup integer-log10 ] dip
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ format-scientific-mantissa ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ drop nip format-scientific-exponent ] 3bi append
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-19 20:15:05 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] keepd neg? [ CHAR: - prefix ] when ;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-24 11:01:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: format-float-fast ( x digits string -- string )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ "" -1 ] 2dip "C" format-float ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: format-fast-scientific? ( x digits -- x' digits ? )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    over float? [ t ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ 2dup
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-06 17:36:29 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        [ [ t ] [ abs integer-log10 abs 308 < ] if-zero ]
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-24 11:01:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        [ 15 < ] bi* and
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ [ [ >float ] dip ] when ] keep
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] if ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: format-scientific ( x digits -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-26 10:55:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    format-fast-scientific?  [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ "e" format-float-fast ]
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-06 18:21:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        [ [ ".0e" "e" replace ] [ drop ] if-zero ] bi
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-26 10:55:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] [ format-scientific-simple ] if ;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-24 11:01:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: format-fast-decimal? ( x digits -- x' digits ? )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    over float? [ t ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        2dup
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ drop dup integer?  [ abs 53 2^ < ] [ drop f ] if ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ over ratio?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            [ [ abs integer-log10 ] dip
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              [ drop abs 308 < ] [ + 15 <= ] 2bi and ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            [ 2drop f ] if
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] 2bi or
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ [ [ >float ] dip ] when ] keep
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] if ; inline
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: format-decimal ( x digits -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-26 10:55:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    format-fast-decimal? [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [ "f" format-float-fast ]
							 | 
						
					
						
							
								
									
										
										
										
											2017-07-06 18:21:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        [ [ ".0" ?tail drop ] [ drop ] if-zero ] bi
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-26 10:55:49 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] [ format-decimal-simple ] if ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-14 00:24:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 23:23:57 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								EBNF: parse-printf [=[
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								zero      = "0"                  => [[ CHAR: 0 ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								char      = "'" (.)              => [[ second ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								pad-char  = (zero|char)?         => [[ CHAR: \s or ]]
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-23 03:19:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								pad-align = ("-")?               => [[ \ pad-tail \ pad-head ? ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								pad-width = ([0-9])*             => [[ >digits ]]
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-20 12:40:30 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								pad       = pad-align pad-char pad-width => [[ <reversed> >quotation dup first 0 = [ drop [ ] ] when ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-26 09:15:47 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								sign_     = [+ ]                 => [[ '[ dup first CHAR: - = [ _ prefix ] unless ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-17 20:50:00 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								sign      = (sign_)?             => [[ [ ] or ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-16 17:05:30 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								width_    = "." ([0-9])*         => [[ second >digits '[ _ short head ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-23 03:19:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								width     = (width_)?            => [[ [ ] or ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								digits_   = "." ([0-9])*         => [[ second >digits ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								digits    = (digits_)?           => [[ 6 or ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-%     = "%"                  => [[ "%" ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-c     = "c"                  => [[ [ 1string ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-C     = "C"                  => [[ [ 1string >upper ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-14 00:24:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-s     = "s"                  => [[ [ present ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-S     = "S"                  => [[ [ present >upper ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-09 20:52:15 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-u     = "u"                  => [[ [ unparse ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-10 16:31:26 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-d     = "d"                  => [[ [ >integer number>string ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-o     = "o"                  => [[ [ >integer >oct ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-b     = "b"                  => [[ [ >integer >bin ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-14 00:24:35 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-e     = digits "e"           => [[ first '[ _ format-scientific ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-E     = digits "E"           => [[ first '[ _ format-scientific >upper ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-f     = digits "f"           => [[ first '[ _ format-decimal ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-10 16:31:26 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-x     = "x"                  => [[ [ >integer >hex ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-X     = "X"                  => [[ [ >integer >hex >upper ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-18 11:53:29 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								unknown   = (.)*                 => [[ "" like unknown-format-directive ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-09 20:52:15 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								strings_  = fmt-c|fmt-C|fmt-s|fmt-S|fmt-u
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-20 12:40:30 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								strings   = pad width strings_   => [[ <reversed> compose-all ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-06-10 16:31:26 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								numbers_  = fmt-d|fmt-o|fmt-b|fmt-e|fmt-E|fmt-f|fmt-x|fmt-X
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								numbers   = sign pad numbers_    => [[ unclip-last prefix compose-all [ fix-sign ] append ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-23 03:19:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								types     = strings|numbers
							 | 
						
					
						
							
								
									
										
										
										
											2009-01-30 17:17:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-24 14:11:15 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								lists     = "[%" types ", %]"    => [[ second '[ _ { } map-as ", " join "{ " " }" surround ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2009-01-30 17:17:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-03-24 14:13:55 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								assocs    = "[%" types ": %" types " %]" => [[ [ second ] [ fourth ] bi '[ [ _ _ bi* ":" glue ] { } assoc>map ", " join "{ " " }" surround ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2009-01-30 17:17:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								formats   = "%" (types|fmt-%|lists|assocs|unknown) => [[ second ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								plain-text = (!("%").)+          => [[ >string ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								text      = (formats|plain-text)* => [[ ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 23:23:57 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								]=]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: printf-quot ( format-string -- format-quot n )
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    parse-printf [ [ callable? ] count ] keep [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        dup string? [ 1quotation ] [ [ 1 - ] dip ] if
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        over [ ndip ] 2curry
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] map nip [ compose-all ] [ length ] bi ; inline
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								PRIVATE>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-19 01:16:11 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								MACRO: printf ( format-string -- quot )
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf-quot '[
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        @ output-stream get [ stream-write ] curry _ napply
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-19 14:42:46 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								MACRO: sprintf ( format-string -- quot )
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    printf-quot '[
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        @ _ "" nappend-as
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-14 12:22:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: vprintf ( seq format-string -- )
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-10 23:39:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    parse-printf output-stream get '[
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        dup string? [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            [ unclip-slice ] dip call( x -- y )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] unless _ stream-write
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] each drop ;
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-14 12:22:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: vsprintf ( seq format-string -- result )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ vprintf ] with-string-writer ; inline
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								<PRIVATE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: pad-00 ( n -- string )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    number>string 2 CHAR: 0 pad-head ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-16 17:05:30 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: pad-000 ( n -- string )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    number>string 3 CHAR: 0 pad-head ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: >time ( timestamp -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ hour>> ] [ minute>> ] [ second>> floor ] tri
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ pad-00 ] tri@ 3array ":" join ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: >date ( timestamp -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ month>> ] [ day>> ] [ year>> ] tri
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ pad-00 ] tri@ 3array "/" join ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: >datetime ( timestamp -- string )
							 | 
						
					
						
							
								
									
										
										
										
											2009-05-03 18:23:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          [ day-of-week day-abbreviation3 ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          [ month>> month-abbreviation ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          [ day>> pad-00 ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          [ >time ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          [ year>> number>string ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								       } cleave
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] output>array " " join ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: week-of-year ( timestamp day -- n )
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ dup clone 1 >>month 1 >>day day-of-week dup ] dip > [ 7 swap - ] when
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-14 15:27:23 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ day-of-year ] dip 2dup < [ 0 2nip ] [ - 7 / 1 + >fixnum ] if ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: week-of-year-sunday ( timestamp -- n ) 0 week-of-year ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-06 12:26:17 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: week-of-year-monday ( timestamp -- n ) 1 week-of-year ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 23:23:57 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								EBNF: parse-strftime [=[
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 19:11:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fmt-%     = "%"                  => [[ "%" ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-a     = "a"                  => [[ [ day-of-week day-abbreviation3 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-A     = "A"                  => [[ [ day-of-week day-name ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-b     = "b"                  => [[ [ month>> month-abbreviation ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-B     = "B"                  => [[ [ month>> month-name ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-c     = "c"                  => [[ [ >datetime ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-d     = "d"                  => [[ [ day>> pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-H     = "H"                  => [[ [ hour>> pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-I     = "I"                  => [[ [ hour>> dup 12 > [ 12 - ] when pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-j     = "j"                  => [[ [ day-of-year pad-000 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-m     = "m"                  => [[ [ month>> pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-M     = "M"                  => [[ [ minute>> pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-p     = "p"                  => [[ [ hour>> 12 < "AM" "PM" ? ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-S     = "S"                  => [[ [ second>> floor pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-U     = "U"                  => [[ [ week-of-year-sunday pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-w     = "w"                  => [[ [ day-of-week number>string ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-W     = "W"                  => [[ [ week-of-year-monday pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-x     = "x"                  => [[ [ >date ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-X     = "X"                  => [[ [ >time ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-y     = "y"                  => [[ [ year>> 100 mod pad-00 ] ]]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-Y     = "Y"                  => [[ [ year>> number>string ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fmt-Z     = "Z"                  => [[ [ "Not yet implemented" throw ] ]]
							 | 
						
					
						
							
								
									
										
										
										
											2018-01-18 11:53:29 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								unknown   = (.)*                 => [[ "" like unknown-format-directive ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								formats_  = fmt-%|fmt-a|fmt-A|fmt-b|fmt-B|fmt-c|fmt-d|fmt-H|fmt-I|
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            fmt-j|fmt-m|fmt-M|fmt-p|fmt-S|fmt-U|fmt-w|fmt-W|fmt-x|
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            fmt-X|fmt-y|fmt-Y|fmt-Z|unknown
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 19:11:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								formats   = "%" (formats_)       => [[ second ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 19:11:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								plain-text = (!("%").)+          => [[ >string ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 19:11:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								text      = (formats|plain-text)* => [[ ]]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-08-05 23:23:57 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								]=]
							 | 
						
					
						
							
								
									
										
										
										
											2008-12-15 17:43:01 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								PRIVATE>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-07-19 01:16:11 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								MACRO: strftime ( format-string -- quot )
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 19:11:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    parse-strftime [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        dup string? [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            '[ _ swap push-all ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            '[ over @ swap push-all ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] if
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] map '[
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        SBUF" " clone [ _ cleave drop ] keep "" like
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] ;
							 |