From e10754a298da8aefa97edcbf46fddca7114f45c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Lindqvist?= Date: Tue, 3 Jan 2017 15:30:59 +0100 Subject: [PATCH] tools.cal: using strftime + tests --- extra/tools/cal/cal-tests.factor | 14 ++++++++++++++ extra/tools/cal/cal.factor | 12 +++++------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 extra/tools/cal/cal-tests.factor diff --git a/extra/tools/cal/cal-tests.factor b/extra/tools/cal/cal-tests.factor new file mode 100644 index 0000000000..ce4115e371 --- /dev/null +++ b/extra/tools/cal/cal-tests.factor @@ -0,0 +1,14 @@ +USING: calendar tools.cal.private tools.test ; +IN: tools.cal.tests + +{ + " October 2010 " +} [ + 2010 10 10 month-header +] unit-test + +{ + " 2010 " +} [ + 2010 10 10 year-header +] unit-test diff --git a/extra/tools/cal/cal.factor b/extra/tools/cal/cal.factor index c0be27e16f..f887585baa 100644 --- a/extra/tools/cal/cal.factor +++ b/extra/tools/cal/cal.factor @@ -1,10 +1,8 @@ ! Copyright (C) 2016 John Benediktsson ! See http://factorcode.org/license.txt for BSD license - -USING: accessors calendar combinators command-line formatting -grouping io kernel math.parser math.ranges namespaces sequences -sequences.extras strings.tables ; - +USING: accessors calendar combinators command-line +formatting grouping io kernel math.parser math.ranges namespaces +sequences sequences.extras strings.tables ; IN: tools.cal > ] bi "%s %s" sprintf + "%B %Y" strftime 20 CHAR: \s pad-center ; : year-header ( timestamp -- str ) - year>> "%s" sprintf 64 CHAR: \s pad-center ; + "%Y" strftime 64 CHAR: \s pad-center ; : month-rows ( timestamp -- rows ) days 7 group day-abbreviations2 prefix format-table ; -- 2.34.1