Bert Leunis pushed to branch master at cms-community / 
hippo-addon-channel-manager


Commits:
b579f1ec by Bert Leunis at 2018-03-27T13:37:19+02:00
CHANNELMGR-1391 initialize date picker correctly for non English locales

Use ISO format to initialize the JavaScript Date object.

- - - - -


2 changed files:

- 
frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.js
- 
frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.spec.js


Changes:

=====================================
frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.js
=====================================
--- 
a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.js
+++ 
b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.js
@@ -45,7 +45,7 @@ class DateValue {
 
   _initJsDate() {
     // use only the year, month and day of the moment and ignore the time and 
time zone
-    this.jsDate = new Date(this.moment.format('L'));
+    this.jsDate = new Date(this.moment.format('YYYY-MM-DD'));
   }
 
   _initBlank() {


=====================================
frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.spec.js
=====================================
--- 
a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.spec.js
+++ 
b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/fields/dateField/dateValue.model.spec.js
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+import moment from 'moment-timezone';
 import DateValue from './dateValue.model';
 
 describe('DateValue', () => {
@@ -79,6 +80,13 @@ describe('DateValue', () => {
       expect(dateValue.date.getMonth()).toBe(monthBefore);
       expect(dateValue.date.getDate()).toBe(dayBefore);
     });
+
+    it('initializes the JavaScript date correctly for a non English locale', 
() => {
+      const dateValue = new DateValue('');
+      const germanMoment = moment().locale('de');
+      dateValue._init(germanMoment);
+      expect(dateValue.jsDate.getTime()).not.toBeNaN();
+    });
   });
 
   describe('when populated with time zone', () => {



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/b579f1ec6f5baac1d8d5ba8f485510799a8f4481

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/b579f1ec6f5baac1d8d5ba8f485510799a8f4481
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to