You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2012/12/14 19:02:01 UTC
svn commit: r1422012 -
/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Author: gcrawford
Date: Fri Dec 14 18:02:00 2012
New Revision: 1422012
URL: http://svn.apache.org/viewvc?rev=1422012&view=rev
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/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js?rev=1422012&r1=1422011&r2=1422012&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js Fri Dec 14 18:02:00 2012
@@ -23,6 +23,8 @@
var _AD_ERA = null;
var _THAI_BUDDHIST_YEAR_OFFSET = 543;
+var _MILLIS_PER_DAY = 86400000;
+
function _getADEra()
{
if (_AD_ERA == null)
@@ -231,9 +233,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
{
var dayOfWeek = time.getDay();