myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gcrawf...@apache.org
Subject svn commit: r1462383 - /myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Date Fri, 29 Mar 2013 02:41:02 GMT
Author: gcrawford
Date: Fri Mar 29 02:41:02 2013
New Revision: 1462383

URL: http://svn.apache.org/r1462383
Log:
TRINIDAD-2333 When date format is set as Day of Year, only a text "(Day of Year)" is returned


Thanks to anshu

Modified:
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=1462383&r1=1462382&r2=1462383&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Fri Mar 29 02:41:02 2013
@@ -22,6 +22,7 @@
 
 var _AD_ERA = null;
 
+var _MILLIS_PER_DAY = 86400000;
 
 function _getADEra()
 {
@@ -231,8 +232,16 @@ function _subformat(
     switch (formatType)
     {
       case 'D': // day in year
-        appendString = "(Day in Year)";
-        break;
+      {
+        var firstDayInYear = new Date(time.getFullYear(), 0, 1);
+        var millisSinceFirstDayInYear = time - firstDayInYear;
+        var daysSinceFirstDayInYear = Math.floor(millisSinceFirstDayInYear / _MILLIS_PER_DAY);
+
+        // The above calculation produces a zero-based value (eg. daysSinceFirstDateInYear
for Jan 1 is 0), but
+        // the "day in year" value should be 1-based (eg. Jan 1 should be day 1), so we tack
on 1 now.
+        appendString = (daysSinceFirstDayInYear + 1);
+      }
+      break;
       
       case 'E': // day in week
       {



Mime
View raw message