From aa588f98bac3b002ed3e94f6d9012e0c85cd60c0 Mon Sep 17 00:00:00 2001 From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org> Date: Sun, 30 May 1999 22:29:47 +0200 Subject: [PATCH] docfix Rev: lib/modules/Calendar.pmod/Gregorian.pmod:1.20 Rev: lib/modules/Calendar.pmod/module.pmod:1.4 --- lib/modules/Calendar.pmod/Gregorian.pmod | 2 +- lib/modules/Calendar.pmod/module.pmod | 70 ++++++++++++++++++++---- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/lib/modules/Calendar.pmod/Gregorian.pmod b/lib/modules/Calendar.pmod/Gregorian.pmod index 5b4dd82495..75439ea409 100644 --- a/lib/modules/Calendar.pmod/Gregorian.pmod +++ b/lib/modules/Calendar.pmod/Gregorian.pmod @@ -1,6 +1,6 @@ // by Mirar -//! +//! module Calendar //! submodule Gregorian //! time units: //! <ref>Year</ref>, <ref>Month</ref>, <ref>Week</ref>, <ref>Day</ref> diff --git a/lib/modules/Calendar.pmod/module.pmod b/lib/modules/Calendar.pmod/module.pmod index 3dcbc46022..8c453855ce 100644 --- a/lib/modules/Calendar.pmod/module.pmod +++ b/lib/modules/Calendar.pmod/module.pmod @@ -198,35 +198,81 @@ string print_month(void|object month,void|mapping options) if (!month) // resolv thing here is to avoid compile-time resolve month=master()->resolv("Calendar")["Gregorian"]["Month"](); + options=(["mark_today":1, + "week_space":3, + "weeks":1, + "days":1, + "title":1, + "notes":([])]) | (options || ([])); + options=(["date_space":(options->mark_today?3:2)])|options; + + today=function_object(object_program(month))->Day(); - res=sprintf(" %|28s\n", - String.capitalize(month->name()+" ") - +month->year()->name()); - w=month->day(1)->week(); - res+=" "; - foreach (Array.map(w->days(),w->day)->week_day_name(),string n) - res+=sprintf("%3s ",n[0..2]); - res+="\n"; + res=""; + if (options->weeks) res+=" "+" "*options->week_space; + if (options->title) + res+=sprintf("%|*s\n", + (1+options->date_space)*sizeof(w->days())-1, + intp(options->title) + ?(String.capitalize(month->name()+" ") + +month->year()->name()) + :options->title); + + if (options->days) + { + if (options->weeks) res+=" "+" "*options->week_space; + foreach (Array.map(w->days(),w->day)->week_day_name(),string n) + res+=sprintf("%*s ",options->date_space,n[0..options->date_space-1]); + res+="\n"; + } + + string daynotes=""; + + if (sizeof(Array.filter( + Array.map(month->days(),month->day), + lambda(object d) { return !!options->notes[d]; }))) + daynotes="\n%-|"+options->date_space+"s"; do { array a; + array b; object d; + string format=""; + a=Array.map(Array.map(w->days(),w->day), lambda(object d) { if (d->month()!=month) return 0; else return d; }); - res+=sprintf("%3s ",w->name()); + if (options->weeks) + res+=sprintf("%*s ",options->week_space,w->name()); foreach (a,d) if (d) - if (d!=today) res+=sprintf(" %2d ",d->month_day()); - else res+=sprintf(">%2d<",d->month_day()); - else res+=" "; + if (!options->mark_today || d!=today) + res+=sprintf("%* |d ", + options->date_space, + d->month_day()); + else + res+=sprintf(">%* |d<", + options->date_space-1, + d->month_day()); + else res+=" "+" "*options->date_space; + + if (options->notes[w]) + res+=sprintf("%-=*s", + options->week_note_column_width, + options->notes[w]); res+="\n"; + + if (daynotes) + { + + } + w++; } while (w->day(0)->month()==month); -- GitLab