18 package org.turro.html.calendar;
20 import java.io.IOException;
21 import java.util.Calendar;
22 import java.util.Date;
23 import java.util.Locale;
24 import org.turro.string.ObjectString;
25 import org.turro.elephant.context.IElement;
26 import org.turro.elephant.impl.util.Localizer;
27 import org.turro.html.HTMLComponent;
28 import org.turro.i18n.I_;
44 locale =
I_.
api().used();
51 date = (Date) ObjectString.parseString(sdate, ObjectString.COMPRESSED_DATE_PATTERN, Date.class,
true);
62 Calendar today = Calendar.getInstance(
locale);
63 Calendar cal = Calendar.getInstance(
locale);
65 cal.set(Calendar.HOUR_OF_DAY, today.get(Calendar.HOUR_OF_DAY));
66 cal.set(Calendar.MINUTE, today.get(Calendar.MINUTE));
67 cal.set(Calendar.SECOND, 0);
76 Calendar cal = Calendar.getInstance(
locale);
78 int day = cal.get(Calendar.DAY_OF_MONTH),
79 month = cal.get(Calendar.MONTH),
80 year = cal.get(Calendar.YEAR);
91 for(
int i = 0; i < 7; i++) {
104 "?calweek=" + cal.get(Calendar.WEEK_OF_YEAR),
108 write(
"" + cal.get(Calendar.WEEK_OF_YEAR));
111 for(
int i = 0; i < 7; i++) {
112 if(cal.get(Calendar.MONTH) == month) {
113 if(cal.get(Calendar.DAY_OF_MONTH) == day) {
124 "?caldate=" + ObjectString.formatObject(cal.getTime(), ObjectString.COMPRESSED_DATE_PATTERN,
false),
128 write(
"" + cal.get(Calendar.DAY_OF_MONTH));
131 cal.add(Calendar.DAY_OF_MONTH, 1);
134 if(cal.get(Calendar.MONTH) > month || cal.get(Calendar.YEAR) > year)
break;
137 startTag(
"div",
"class='wcalfooter'");
139 renderPreviousMonth();
144 private void renderToday() {
146 "?caldate=" + ObjectString.formatObject(
new Date(), ObjectString.COMPRESSED_DATE_PATTERN,
false),
153 private void renderPreviousMonth() {
154 Calendar cal = Calendar.getInstance(
locale);
156 cal.add(Calendar.MONTH, -1);
158 "?caldate=" + ObjectString.formatObject(cal.getTime(), ObjectString.COMPRESSED_DATE_PATTERN,
false),
161 startTag(
"span",
"class='previous'");
162 write(monthNames[cal.get(Calendar.MONTH)]);
167 private void renderNextMonth() {
168 Calendar cal = Calendar.getInstance(
locale);
170 cal.add(Calendar.MONTH, 1);
172 "?caldate=" + ObjectString.formatObject(cal.getTime(), ObjectString.COMPRESSED_DATE_PATTERN,
false),
176 write(monthNames[cal.get(Calendar.MONTH)]);
181 private void renderMonthTitle() {
183 startTag(
"div",
"class='wcaltitle'");
184 write(localizer.parseValue(
"date",
"month_year",
date));
HTMLGenerator endAllTags()
HTMLGenerator startTag(String tag)
HTMLGenerator startAnchor(String url, String hint)
HTMLGenerator write(String value)
static String[] getDayNames(Locale locale)
static String[] getMonthNames(Locale locale)
static void positionFirstCell(Calendar date)
void setDayRenderer(IDayRenderer dayRenderer)
HTMLCalendar(IElement iel)
static String get(String msg)
static I18nApiWrapper api()
String getParameter(String param)
void setSessionAttribute(String key, Object value)
Object getSessionAttribute(String key)
IConstructor getConstructor()
void renderDay(Date date, HTMLCalendar calendar)