tools.cal: using strftime + tests

char-rename
Björn Lindqvist 2017-01-03 15:30:59 +01:00
parent 350de8f171
commit e10754a298
2 changed files with 19 additions and 7 deletions

View File

@ -0,0 +1,14 @@
USING: calendar tools.cal.private tools.test ;
IN: tools.cal.tests
{
" October 2010 "
} [
2010 10 10 <date> month-header
] unit-test
{
" 2010 "
} [
2010 10 10 <date> year-header
] unit-test

View File

@ -1,10 +1,8 @@
! Copyright (C) 2016 John Benediktsson ! Copyright (C) 2016 John Benediktsson
! See http://factorcode.org/license.txt for BSD license ! See http://factorcode.org/license.txt for BSD license
USING: accessors calendar combinators command-line
USING: accessors calendar combinators command-line formatting formatting grouping io kernel math.parser math.ranges namespaces
grouping io kernel math.parser math.ranges namespaces sequences sequences sequences.extras strings.tables ;
sequences.extras strings.tables ;
IN: tools.cal IN: tools.cal
<PRIVATE <PRIVATE
@ -16,11 +14,11 @@ IN: tools.cal
42 " " pad-tail ; 42 " " pad-tail ;
: month-header ( timestamp -- str ) : month-header ( timestamp -- str )
[ month-name ] [ year>> ] bi "%s %s" sprintf "%B %Y" strftime
20 CHAR: \s pad-center ; 20 CHAR: \s pad-center ;
: year-header ( timestamp -- str ) : year-header ( timestamp -- str )
year>> "%s" sprintf 64 CHAR: \s pad-center ; "%Y" strftime 64 CHAR: \s pad-center ;
: month-rows ( timestamp -- rows ) : month-rows ( timestamp -- rows )
days 7 group day-abbreviations2 prefix format-table ; days 7 group day-abbreviations2 prefix format-table ;