You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/01/04 09:26:27 UTC

svn commit: r608772 - /myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/popcalendar.js

Author: skitching
Date: Fri Jan  4 00:26:23 2008
New Revision: 608772

URL: http://svn.apache.org/viewvc?rev=608772&view=rev
Log:
Use new SimpleDateFormatter method getDateForWeekDate.

Modified:
    myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/popcalendar.js

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/popcalendar.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/popcalendar.js?rev=608772&r1=608771&r2=608772&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/popcalendar.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/calendar/resource/popcalendar.js Fri Jan  4 00:26:23 2008
@@ -1076,7 +1076,7 @@
     var cell = document.createElement("td");
     cell.setAttribute("style", "text-align:right;");
 
-    var weekNumber = this.stdDateFormatter.getWeekDate(startDate).week;
+    var weekDate = this.stdDateFormatter.getWeekDate(startDate);
     if (weekSelectable)
     {
         var link = document.createElement("a");
@@ -1084,38 +1084,9 @@
         link.sNormalStyle = sNormalStyle;
         link.sSelectStyle = sSelectStyle;
         link.setAttribute("href", "#");
-        link.appendChild(document.createTextNode(weekNumber + " "));
+        link.appendChild(document.createTextNode(weekDate.week + " "));
 
-        // The day on which the week starts is simply the first day of the year + week*7
-        // Note that this might not match the first day on the same calendar row as the
-        // selected weeknumber. However it does ensure that week N is exactly seven days
-        // different from week N+1, and also that the first week of the year starts on
-        // the first day of the year.
-        //
-        // Note that this does mean that when clicking on the last week in a month, the
-        // selected date might be the first day in the following month.
-        var yearStart;
-        if ((this.selectedDate.month==11) && (weekNumber==1))
-        {
-            // handle corner case where we are displaying December of a year, and the user
-            // clicks on the last week entry, which is actually week1 of the following year.
-            //
-            // Todo: maybe this is a bug, and this should be "week53" of the previous year.
-            // But in that case, the concrete date we would return for "week53 of 2000"
-            // would be "2001.01.01", which also feels wrong.
-            yearStart = new Date(this.selectedDate.year + 1, 0, 1);
-        }
-        else if ((this.selectedDate.month==0) && (weekNumber>50))
-        {
-            yearStart = new Date(this.selectedDate.year - 1, 0, 1);
-        }
-        else
-        {
-            yearStart = new Date(this.selectedDate.year, 0, 1);
-        }
-        var msecs = yearStart.getTime() + this._MSECS_PER_DAY*7*(weekNumber-1);
-        link.dateObj = new Date();
-        link.dateObj.setTime(msecs);
+        link.dateObj = this.stdDateFormatter.getDateForWeekDate(weekDate);
 
         cell.appendChild(link);
 
@@ -1153,7 +1124,7 @@
     {
         var span = document.createElement("span");
         span.className=sNormalStyle;
-        span.appendChild(document.createTextNode(weekNumber + " "));
+        span.appendChild(document.createTextNode(weekDate.week + " "));
         cell.appendChild(span);
     }