Permalink
Browse files

I discovered while using trunk demo that getServerTimestampAsLong is …

…not enough. Because Javascript always creates the dates without taking into account the TimeZone. I mean there are OOTB no ways to do otherwise and date.format.js does not help. This makes sense from a HTTP client perspective, but nowadays it's really aging with Ajax, etc.

Fortunately there is a miraculous script which helps much: date.timezone.js. I have introduced it with a getServerTimeZone service. I tested locally by setting another timezone on another machine and it worked. I will now test it on trunk, I don't expect any issues

I also cleaned the NOTICE for famfamfam




git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1432577 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent b72977f commit 3bbe96580d1dda2b581793c816e9a42e60256075 @JacquesLeRoux JacquesLeRoux committed Jan 13, 2013
Showing with 23,989 additions and 41 deletions.
  1. +3 −3 LICENSE
  2. +28 −17 NOTICE
  3. +10 −4 framework/common/script/org/ofbiz/common/CommonServices.xml
  4. +10 −5 framework/common/servicedef/services.xml
  5. +11 −4 framework/common/webcommon/WEB-INF/common-controller.xml
  6. +8 −4 framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl
  7. +2 −1 framework/common/widget/CommonScreens.xml
  8. 0 framework/images/webapp/images/{ → date}/date.format-1.2.3
  9. 0 framework/images/webapp/images/{ → date}/date.format-1.2.3-min.js
  10. +1 −0 framework/images/webapp/images/date/date.timezone-min.js
  11. +913 −0 framework/images/webapp/images/date/date.timezone.js
  12. +503 −0 framework/images/webapp/images/date/timezones/Makefile
  13. +1,181 −0 framework/images/webapp/images/date/timezones/africa
  14. +413 −0 framework/images/webapp/images/date/timezones/antarctica
  15. +2,717 −0 framework/images/webapp/images/date/timezones/asia
  16. +1,719 −0 framework/images/webapp/images/date/timezones/australasia
  17. +117 −0 framework/images/webapp/images/date/timezones/backward
  18. +81 −0 framework/images/webapp/images/date/timezones/etcetera
  19. +2,856 −0 framework/images/webapp/images/date/timezones/europe
  20. +10 −0 framework/images/webapp/images/date/timezones/factory
  21. +276 −0 framework/images/webapp/images/date/timezones/iso3166.tab
  22. +100 −0 framework/images/webapp/images/date/timezones/leapseconds
  23. +217 −0 framework/images/webapp/images/date/timezones/min/Makefile
  24. +326 −0 framework/images/webapp/images/date/timezones/min/africa
  25. +112 −0 framework/images/webapp/images/date/timezones/min/antarctica
  26. +725 −0 framework/images/webapp/images/date/timezones/min/asia
  27. +311 −0 framework/images/webapp/images/date/timezones/min/australasia
  28. +110 −0 framework/images/webapp/images/date/timezones/min/backward
  29. +36 −0 framework/images/webapp/images/date/timezones/min/etcetera
  30. +1,075 −0 framework/images/webapp/images/date/timezones/min/europe
  31. +1 −0 framework/images/webapp/images/date/timezones/min/factory
  32. +249 −0 framework/images/webapp/images/date/timezones/min/iso3166.tab
  33. +25 −0 framework/images/webapp/images/date/timezones/min/leapseconds
  34. +975 −0 framework/images/webapp/images/date/timezones/min/northamerica
  35. +1 −0 framework/images/webapp/images/date/timezones/min/pacificnew
  36. +369 −0 framework/images/webapp/images/date/timezones/min/solar87
  37. +370 −0 framework/images/webapp/images/date/timezones/min/solar88
  38. +369 −0 framework/images/webapp/images/date/timezones/min/solar89
  39. +516 −0 framework/images/webapp/images/date/timezones/min/southamerica
  40. +8 −0 framework/images/webapp/images/date/timezones/min/systemv
  41. +33 −0 framework/images/webapp/images/date/timezones/min/yearistype.sh
  42. +415 −0 framework/images/webapp/images/date/timezones/min/zone.tab
  43. +3,235 −0 framework/images/webapp/images/date/timezones/northamerica
  44. +28 −0 framework/images/webapp/images/date/timezones/pacificnew
  45. +390 −0 framework/images/webapp/images/date/timezones/solar87
  46. +390 −0 framework/images/webapp/images/date/timezones/solar88
  47. +395 −0 framework/images/webapp/images/date/timezones/solar89
  48. +1,711 −0 framework/images/webapp/images/date/timezones/southamerica
  49. +30 −0 framework/images/webapp/images/date/timezones/strip_olson_comments.rb
  50. +58 −0 framework/images/webapp/images/date/timezones/strip_olson_comments_ofbiz.rb
  51. +38 −0 framework/images/webapp/images/date/timezones/systemv
  52. +38 −0 framework/images/webapp/images/date/timezones/yearistype.sh
  53. +441 −0 framework/images/webapp/images/date/timezones/zone.tab
  54. +33 −3 framework/images/webapp/images/miscAjaxFunctions.js
View
@@ -125,6 +125,7 @@ ofbiz/trunk/applications/product/lib/dozer-4.2.1.jar
ofbiz/trunk/applications/product/lib/watermarker-0.0.4.jar
ofbiz/trunk/applications/content/template/docbook/extensions/webhelpindexer.jar
ofbiz/trunk/specialpurpose/googlecheckout/lib/checkout-sdk-0.8.8.jar
+ofbiz/trunk/framework/images/webapp/images/date/timezones*
=========================================================================
Apache License
Version 2.0, January 2004
@@ -1235,7 +1236,7 @@ ofbiz/trunk/framework/images/webapp/images/jquery/*
ofbiz/trunk/specialpurpose/webpos/webapp/webpos/images/js/jquery.hotkeys-0.7.9.min.js
ofbiz/trunk/specialpurpose/webpos/webapp/webpos/images/js/WebPosHotkeys.js
ofbiz/trunk/applications/content/template/docbook/webhelp/*
-ofbiz/trunk/framework/images/webapp/images/date.format-1.2.3.js
+ofbiz/trunk/framework/images/webapp/images/date/date.format-1.2.3*.js
=========================================================================
The MIT License
@@ -2802,10 +2803,9 @@ OF SUCH DAMAGES.
Web-based Help from DocBook XML license
David Cramer <dcramer AT motive DOT com><david AT thingbag DOT net>
Kasun Gajasinghe <kasunbg AT gmail DOT com>
-Copyright � 2008-2010 Kasun Gajasinghe, David Cramer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
-and associated documentation files (the Software), to deal in the Software without restriction,
+and associated documentation files (the Software), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
View
45 NOTICE
@@ -350,40 +350,51 @@ Extreme! Lab (http://www.extreme.indiana.edu/).
== jline Notice ==
=========================================================================
-This product includes software developed by Marc Prud'hommeaux
-<mwp1@cornell.edu>
+This product includes software developed by Marc Prud'hommeaux
+<mwp1@cornell.edu>
=========================================================================
== FamFamFam Notice ==
=========================================================================
This product includes images delevoped by Mark James <mjames@gmail.com>
Birmingham, UK. www.famfamfam.com
-Creative Commons Attribution 2.5 License.
+Creative Commons Attribution 2.5 License Generic.
http://creativecommons.org/licenses/by/2.5/
You are free:
- * to Share — to copy, distribute and transmit the work
- * to Remix — to adapt the work
+ * to Share — to copy, distribute and transmit the work
+ * to Remix — to adapt the work
+ * to make commercial use of the work
Under the following conditions:
- * Attribution. You must attribute the work in the manner specified
- by the author or licensor (but not in any way that suggests that
- they endorse you or your use of the work).
- * For any reuse or distribution, you must make clear to
- others the license terms of this work. The best way to do
- this is with a link to this web page.
- * Any of the above conditions can be waived if you get
- * For any reuse or distribution, you must make clear to
+ * Attribution — You must attribute the work in the manner specified
+ by the author or licensor (but not in any way that suggests that
+ they endorse you or your use of the work).
+ * Waiver — Any of the above conditions can be waived if you get
permission from the copyright holder.
- * Nothing in this license impairs or restricts the
- * For any reuse or distribution, you must make clear to
- author's moral rights.
+ * Public Domain — Where the work or any of its elements is in the
+ public domain under applicable law, that status is in no way
+ affected by the license.
+ * Other Rights — In no way are any of the following rights affected
+ by the license:
+ * Your fair dealing or fair use rights, or other applicable copyright
+ exceptions and limitations;
+ * The author's moral rights;
+ * Rights other persons may have either in the work itself or in how
+ the work is used, such as publicity or privacy rights.
+ * Notice — For any reuse or distribution, you must make clear to others
+ the license terms of this work. The best way to do this is with a link to
+ this web page.
=========================================================================
This product includes software developed by Steven Levithan
(http://blog.stevenlevithan.com/archives/date-time-format). MIT license
=========================================================================
-
+
+This product includes software developed by Matthew Eernisse (mde@fleegix.org)
+and Open Source Applications Foundation. Licensed under the ASL2
+https://github.com/mde/timezone-js
+=========================================================================
@@ -347,13 +347,19 @@ under the License.
<field-to-result field="exist"/>
</simple-method>
+ <simple-method method-name="getServerTimestamp" login-required="false">
+ <now field="serverTimestamp" type="java.sql.Timestamp"/>
+ <field-to-result field="serverTimestamp"/>
+ </simple-method>
+
+ <simple-method method-name="getServerTimeZone" login-required="false">
+ <set field="serverTimeZone" value="${util:defaultTimeZone()}" type="String"/>
+ <field-to-result field="serverTimeZone"/>
+ </simple-method>
+
<simple-method method-name="getServerTimestampAsLong" login-required="false">
<now field="serverTimestamp" type="java.lang.Long"/>
<field-to-result field="serverTimestamp"/>
</simple-method>
- <simple-method method-name="getServerTimestamp" login-required="false">
- <now field="serverTimestamp" type="java.sql.Timestamp"/>
- <field-to-result field="serverTimestamp"/>
- </simple-method>
</simple-methods>
@@ -781,16 +781,21 @@ under the License.
<attribute name="geoList" mode="OUT" type="java.util.List"/>
</service>
- <service name="getServerTimestampAsLong" engine="simple" auth="false"
- location="component://common/script/org/ofbiz/common/CommonServices.xml" invoke="getServerTimestampAsLong">
- <attribute name="serverTimestamp" mode="OUT" type="Long"/>
- </service>
-
<service name="getServerTimestamp" engine="simple" auth="false"
location="component://common/script/org/ofbiz/common/CommonServices.xml" invoke="getServerTimestamp">
<attribute name="serverTimestamp" mode="OUT" type="TimeStamp"/>
</service>
+ <service name="getServerTimeZone" engine="simple" auth="false"
+ location="component://common/script/org/ofbiz/common/CommonServices.xml" invoke="getServerTimeZone">
+ <attribute name="serverTimeZone" mode="OUT" type="String"/>
+ </service>
+
+ <service name="getServerTimestampAsLong" engine="simple" auth="false"
+ location="component://common/script/org/ofbiz/common/CommonServices.xml" invoke="getServerTimestampAsLong">
+ <attribute name="serverTimestamp" mode="OUT" type="Long"/>
+ </service>
+
<service name="createJsLanguageFileMapping" engine="java" auth="false" use-transaction="false"
location="org.ofbiz.common.JsLanguageFileMappingCreator" invoke="createJsLanguageFileMapping">
<description>Create or update the JsLanguageFilesMapping.java. You still need to compile thereafter</description>
@@ -253,16 +253,23 @@ under the License.
<response name="error" type="request" value="json"/>
</request-map>
- <request-map uri="getServerTimestampAsLong">
+ <request-map uri="getServerTimestamp">
<security https="true" auth="true"/>
- <event type="service" invoke="getServerTimestampAsLong"/>
+ <event type="service" invoke="getServerTimestamp"/>
<response name="success" type="request" value="json"/>
<response name="error" type="request" value="json"/>
</request-map>
- <request-map uri="getServerTimestamp">
+ <request-map uri="getServerTimeZone">
<security https="true" auth="true"/>
- <event type="service" invoke="getServerTimestamp"/>
+ <event type="service" invoke="getServerTimeZone"/>
+ <response name="success" type="request" value="json"/>
+ <response name="error" type="request" value="json"/>
+ </request-map>
+
+ <request-map uri="getServerTimestampAsLong">
+ <security https="true" auth="true"/>
+ <event type="service" invoke="getServerTimestampAsLong"/>
<response name="success" type="request" value="json"/>
<response name="error" type="request" value="json"/>
</request-map>
@@ -20,15 +20,19 @@ under the License.
jQuery(document).ready(function() {
window.setInterval(function(){clock()}, 1000);
var serverTimestamp = 0;
- var date
+ var date;
function clock() {
if (jQuery("#${clockField}").text() === "${uiLabelMap.CommonServerHour}:") {
- serverTimestamp = getServerTimestamp("getServerTimestampAsLong");
- date = new Date(serverTimestamp);
+ serverTimestamp = getServiceResult("getServerTimestampAsLong")['serverTimestamp'];
+ serverTimeZone = getServiceResult("getServerTimeZone")['serverTimeZone'];;
+ initTimeZone();
+ date = new timezoneJS.Date(serverTimestamp, serverTimeZone);
} else {
date.setSeconds(date.getSeconds() + 1);
}
- jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " + dateFormat(date, "yyyy-mm-dd HH:MM:ss"));
+ // dateFormat does not respect the timezone :/ Fortunately toString is what we want :)
+ //jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " + dateFormat(date, "yyyy-mm-dd HH:MM:ss"));
+ jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " + date.toString());
}
})
</script>
@@ -154,9 +154,10 @@ under the License.
<!-- jQuery CSSs -->
<set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true" />
<set field="layoutSettings.javaScripts[]" value="/images/selectall.js" global="true" />
- <set field="layoutSettings.javaScripts[]" value="/images/date.format-1.2.3-min.js" global="true" />
<set field="layoutSettings.javaScripts[]" value="/images/fieldlookup.js" global="true" />
<set field="layoutSettings.javaScripts[]" value="/images/GooglemapMarkers.js" global="true" />
+ <set field="layoutSettings.javaScripts[]" value="/images/date/date.format-1.2.3-min.js" global="true" />
+ <set field="layoutSettings.javaScripts[]" value="/images/date/timezones/date.timezone-min.js" global="true" />
<set field="layoutSettings.javaScripts[]" value="/images/miscAjaxFunctions.js" global="true" />
<set field="layoutSettings.javaScripts[]" value="/images/selectMultipleRelatedValues.js" global="true" />
<set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" global="true" />

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 3bbe965

Please sign in to comment.