cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hepab...@apache.org
Subject svn commit: r289973 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/CalendarGenerator.java
Date Sun, 18 Sep 2005 21:00:20 GMT
Author: hepabolu
Date: Sun Sep 18 14:00:13 2005
New Revision: 289973

URL: http://svn.apache.org/viewcvs?rev=289973&view=rev
Log:
Updated CalendardGenerator to include day_of_week info

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/CalendarGenerator.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/CalendarGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/CalendarGenerator.java?rev=289973&r1=289972&r2=289973&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/CalendarGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/CalendarGenerator.java
Sun Sep 18 14:00:13 2005
@@ -55,10 +55,10 @@
  *     year="2004" month="January" prevMonth="12" prevYear="2003"
  *     nextMonth="02" nextYear="2004">
  *   <calendar:week number="1">
- *     <calendar:day number="1" date="January 1, 2004"/>
- *     <calendar:day number="2" date="January 2, 2004"/>
- *     <calendar:day number="3" date="January 3, 2004"/>
- *     <calendar:day number="4" date="January 4, 2004"/>
+ *     <calendar:day number="1" weekday="THURSDAY" date="January 1, 2004"/>
+ *     <calendar:day number="2" weekday="FRIDAY" date="January 2, 2004"/>
+ *     <calendar:day number="3" weekday="SATURDAY" date="January 3, 2004"/>
+ *     <calendar:day number="4" weekday="SUNDAY" date="January 4, 2004"/>
  *   </calendar:week>
  *   ...
  * </calendar:calendar>
@@ -106,6 +106,7 @@
     protected static final String YEAR_ATTR_NAME       = "year";
     protected static final String DATE_ATTR_NAME       = "date";
     protected static final String NUMBER_ATTR_NAME     = "number";
+	protected static final String WEEKDAY_ATTR_NAME    = "weekday";
     protected static final String PREV_MONTH_ATTR_NAME = "prevMonth";
     protected static final String PREV_YEAR_ATTR_NAME  = "prevYear";
     protected static final String NEXT_MONTH_ATTR_NAME = "nextMonth";
@@ -141,6 +142,16 @@
     /** Do we need to pad out the first and last weeks? */
     protected boolean padWeeks;
     
+	/* Add the day of the week 
+	 * 
+	 * since SUNDAY=1, we start with a dummy
+	 * entry. 
+	 */
+	protected String weekdays[] = { "",
+			"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", 
+			"Friday", "Saturday"
+	};
+	
     /**
      * Set the request parameters. Must be called before the generate method.
      *
@@ -241,6 +252,8 @@
                     attributes.clear();
                     attributes.addAttribute("", NUMBER_ATTR_NAME, NUMBER_ATTR_NAME, "CDATA",
                             String.valueOf(previous.get(Calendar.DAY_OF_MONTH)));
+					attributes.addAttribute("", WEEKDAY_ATTR_NAME, WEEKDAY_ATTR_NAME, "CDATA",
+							weekdays[previous.get(Calendar.DAY_OF_WEEK)]);
                     attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
                             dateFormatter.format(previous.getTime()));
                     this.contentHandler.startElement(URI, DAY_NODE_NAME,
@@ -263,6 +276,8 @@
             attributes.clear();
             attributes.addAttribute("", NUMBER_ATTR_NAME, NUMBER_ATTR_NAME, "CDATA",
                     String.valueOf(start.get(Calendar.DAY_OF_MONTH)));
+			attributes.addAttribute("", WEEKDAY_ATTR_NAME, WEEKDAY_ATTR_NAME, "CDATA",
+					weekdays[start.get(Calendar.DAY_OF_WEEK)]);
             attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
                     dateFormatter.format(start.getTime()));
             this.contentHandler.startElement(URI, DAY_NODE_NAME,
@@ -283,6 +298,8 @@
                 attributes.clear();
                 attributes.addAttribute("", NUMBER_ATTR_NAME, NUMBER_ATTR_NAME, "CDATA",
                         String.valueOf(end.get(Calendar.DAY_OF_MONTH)));
+				attributes.addAttribute("", WEEKDAY_ATTR_NAME, WEEKDAY_ATTR_NAME, "CDATA",
+						weekdays[end.get(Calendar.DAY_OF_WEEK)]);
                 attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
                         dateFormatter.format(end.getTime()));
                 this.contentHandler.startElement(URI, DAY_NODE_NAME,



Mime
View raw message