You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:30:16 UTC

[myfaces-trinidad] 32/33: TRINIDAD-2333 When date format is set as Day of Year, only a text "(Day of Year)" is returned

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 2.0.0.x-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit 42d123f6d496b0a532179fa91b090764b689d564
Author: Gabrielle Crawford <gc...@apache.org>
AuthorDate: Fri Mar 29 02:41:02 2013 +0000

    TRINIDAD-2333 When date format is set as Day of Year, only a text "(Day of Year)" is returned
    
    Thanks to anshu
---
 .../src/main/javascript/META-INF/adf/jsLibs/DateFormat.js   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
index ffe7ec4..95cb442 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/DateFormat.js
@@ -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
       {

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.