]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/tools/cal/cal.factor
calendar.format: format year. in 3 columns, use in tools.cal.
[factor.git] / extra / tools / cal / cal.factor
index 5554aa866a0a8823c077e2c8e690c94f431b0533..5fce897dd31ee8a7dcd73947e65d893f833b629e 100644 (file)
@@ -1,41 +1,10 @@
 ! Copyright (C) 2016 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
-USING: accessors calendar calendar.english combinators
-command-line formatting grouping io kernel math.parser
-math.ranges namespaces sequences sequences.extras strings.tables ;
+USING: accessors calendar calendar.format combinators
+command-line kernel math.parser namespaces sequences
+sequences.extras ;
 IN: tools.cal
 
-<PRIVATE
-
-: days ( timestamp -- days )
-    start-of-month
-    [ day-of-week "  " <repetition> ]
-    [ days-in-month [1,b] [ "%2d" sprintf ] map ] bi append
-    42 "  " pad-tail ;
-
-: month-header ( timestamp -- str )
-    "%B %Y" strftime 20 CHAR: \s pad-center ;
-
-: year-header ( timestamp -- str )
-    "%Y" strftime 64 CHAR: \s pad-center ;
-
-: month-rows ( timestamp -- rows )
-    days 7 group day-abbreviations2 prefix format-table ;
-
-PRIVATE>
-
-: month. ( timestamp -- )
-    [ month-header print ] [ month-rows [ print ] each ] bi ;
-
-: year. ( timestamp -- )
-    dup year-header print nl 12 [1,b] [
-        >>month [ month-rows ] [ month-name ] bi
-        20 CHAR: \s pad-center prefix
-    ] with map 3 group
-    [ first3 [ "%s  %s  %s\n" printf ] 3each ] each ;
-
-<PRIVATE
-
 : cal-args ( -- timestamp year? )
     now command-line get [
         f
@@ -51,8 +20,6 @@ PRIVATE>
         ] dip
     ] if-empty ;
 
-PRIVATE>
-
 : run-cal ( -- )
     cal-args [ year. ] [ month. ] if ;