Author: pvollenweider
Date: Fri Aug 31 13:44:20 2007
New Revision: 772

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D772&repname=
=3Dcorporate_portal_templates_v2
Log:
Fix for TEMPLATES-265
Use the client timezone offset to display the dates

Modified:
    branches/JAHIA-5-0-SP-BRANCH/src/jsp/testFields.jsp

Modified: branches/JAHIA-5-0-SP-BRANCH/src/jsp/testFields.jsp
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/src/jsp/testFields.jsp&rev=3D772&repname=3Dcorporate_portal_templat=
es_v2
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/src/jsp/testFields.jsp (original)
+++ branches/JAHIA-5-0-SP-BRANCH/src/jsp/testFields.jsp Fri Aug 31 13:44:20=
 2007
@@ -55,6 +55,28 @@
 }
 -->
 </style>
+
+<script><!--
+var tmpDate =3D new Date();
+var timeOffSet =3D tmpDate.getTimezoneOffset() * 60 * 1000 * -1;
+function lz(x) {return(x<0||x>9?"":"0")+x}
+function getFormatedDate(x) {
+    if (x =3D=3D 0) {
+        return "n/a";
+    }
+    var timeOffSet =3D (new Date()).getTimezoneOffset() * 60 * 1000 * -1;
+    var calTime =3D x + timeOffSet;
+    var savedDate =3D new Date(calTime);
+    var formatedDate =3D lz(savedDate.getDate()) + "/" +
+        lz(savedDate.getMonth()+1) + "/" +
+        savedDate.getFullYear() + " " +
+        lz(savedDate.getHours()) + ":" +
+        lz(savedDate.getMinutes());
+    return formatedDate;
+}
+//-->
+</script>
+
 <jsp:include page=3D"common/pagetitle.jsp" flush=3D"true"/>
 <jesi:fragment aclGroup=3D"true">
 =

@@ -162,7 +184,7 @@
         <tr><td class=3D"title">Undefined</td><td>
         <content:undefinedField  name=3D'myUndefined'/>
         </td></tr>
-        =

+
         <tr><td class=3D"title">Application</td><td>
         <content:applicationField  name=3D'myApplication'/>
         </td></tr>
@@ -185,6 +207,9 @@
         String publicationDateValue =3D "";
         String expirationDateValue =3D "";
 =

+        long expirationDatelong =3D 0;
+        long publicationDateLong =3D 0;
+
         JahiaObjectManager jahiaObjectManager =3D (JahiaObjectManager) Spr=
ingContextSingleton.getInstance().getContext().getBean(JahiaObjectManager.c=
lass.getName());
 =

         JahiaObjectDelegate jahiaObjectDelegate =3D
@@ -198,6 +223,8 @@
             Calendar cal =3D Calendar.getInstance(TimeZone.getTimeZone("UT=
C"));
             cal.setTimeInMillis(dateLong.longValue()-clientTimeZoneDiff);
             publicationDateValue =3D formater.format(cal.getTime());
+            publicationDateLong =3D cal.getTime().getTime();
+
         } else {
             publicationDateValue =3D JahiaResourceBundle.getEngineResource=
("org.jahia.engines.timebasedpublishing.dateNotAssigned",
                 jParams,jParams.getLocale(),"not assigned");
@@ -208,6 +235,7 @@
             Calendar cal =3D Calendar.getInstance(TimeZone.getTimeZone("UT=
C"));
             cal.setTimeInMillis(dateLong.longValue()-clientTimeZoneDiff);
             expirationDateValue =3D formater.format(cal.getTime());
+            expirationDatelong =3D cal.getTime().getTime();
         } else {
             expirationDateValue =3D JahiaResourceBundle.getEngineResource(=
"org.jahia.engines.timebasedpublishing.dateNotAssigned",
                 jParams,jParams.getLocale(),"not assigned");
@@ -244,8 +272,18 @@
             %>
         </td></tr>
 =

-        <tr><td class=3D"metadata">time base from</td><td><%=3Dpublication=
DateValue%></td></tr>
-        <tr><td class=3D"metadata">time base to</td><td><%=3DexpirationDat=
eValue%></td></tr>
+        <tr><td class=3D"metadata">time base from</td><td>
+            <script><!--
+                document.write(getFormatedDate(<%=3DpublicationDateLong%>)=
);
+            //-->
+            </script>
+        </td></tr>
+        <tr><td class=3D"metadata">time base to</td><td>
+            <script><!--
+            document.write(getFormatedDate(<%=3DexpirationDatelong%>));
+            //-->
+            </script>
+        </td></tr>
 =

     </content:container>
     </table>

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to