Anonymous user
Calendar: Difference between revisions
m
→{{header|Clojure}}
Line 1,996:
(defn month-to-word
"Translate a month from 0 to 11 into its word representation."
[month]
((vec (.getMonths (new java.text.DateFormatSymbols))) month))
Line 2,010:
(defn normal-date-string
"Returns a
[date]
(map #(join " " %)
Line 2,023:
(defn oct-1582-string
"
[date]
(map #(join " " %)
Line 2,040:
(defn center-string
"
[string width]
(let [pad (- width (count string))
Line 2,053:
(defn calc-columns
"
MARGIN SIZE."
[characters margin-size]
(loop [cols 0 excess characters ]
Line 2,062:
(defn month-vector
"Returns a vector with the month name, day-row
formatted for printing."
[date]
(vec (concat
Line 2,074:
(defn year-vector [date]
"
(loop [m [] c (month date)]
(if (= c 11 )
Line 2,083:
(defn print-months
"
[ v ncols margin]
(doseq [r (range (Math/ceil (/ 12 ncols)))]
Line 2,096:
(defn print-cal
"(print-cal [year [width [margin]]])
with MARGIN spaces between months."
([]
(print-cal 1969 80 2))
Line 2,105:
(print-cal year width 2))
([year width margin]
(assert (>= width (count day-row)) "
(assert (> margin 0) "
(let [date (new java.util.GregorianCalendar year 0 1)
column-count (calc-columns width margin)
|