Jump to content

Calendar: Difference between revisions

m
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 formttedformatted list of strings of the days of the month."
[date]
(map #(join " " %)
Line 2,023:
(defn oct-1582-string
" Returns a formatedformatted list of strings of the days of the month of octOctober 1582."
[date]
(map #(join " " %)
Line 2,040:
 
(defn center-string
" ReturnReturns a string that is WIDTH long with STRING centered in it ."
[string width]
(let [pad (- width (count string))
Line 2,053:
 
(defn calc-columns
"CalcutateCalculates the number of columns given the width in CHARACTERS and the
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 and days
formatted for printing."
[date]
(vec (concat
Line 2,074:
 
(defn year-vector [date]
"RetunsReturns a 2d vector of all the months in the year of DATE."
(loop [m [] c (month date)]
(if (= c 11 )
Line 2,083:
 
(defn print-months
"printsPrints the months to standard output with NCOLS and MARGIN ."
[ v ncols margin]
(doseq [r (range (Math/ceil (/ 12 ncols)))]
Line 2,096:
(defn print-cal
"(print-cal [year [width [margin]]])
PrintPrints out the calendar for a given YEAR with WIDTH characters wide and
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)) "widthWidth should be more than 20.")
(assert (> margin 0) "marginMargin needs to be more than 0.")
(let [date (new java.util.GregorianCalendar year 0 1)
column-count (calc-columns width margin)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.