Skip to content

Commit

Permalink
Merge pull request #682 from magento-fearless-kiwis/FearlessKiwis-MAG…
Browse files Browse the repository at this point in the history
…ETWO-62262

Fearless kiwis magetwo 62262
  • Loading branch information
Joan He authored Dec 19, 2016
2 parents 383d18a + c7e851c commit 813fad8
Show file tree
Hide file tree
Showing 6 changed files with 685 additions and 667 deletions.
24 changes: 4 additions & 20 deletions app/code/Magento/Ui/view/base/web/js/form/element/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,38 +167,22 @@ define([
prepareDateTimeFormats: function () {
this.pickerDateTimeFormat = this.options.dateFormat;
this.momentFormat = this.options.dateFormat ?
this.convertToMomentFormat(this.options.dateFormat) : this.momentFormat;
utils.convertToMomentFormat(this.options.dateFormat) : this.momentFormat;

if (this.options.showsTime) {
this.pickerDateTimeFormat += ' ' + this.options.timeFormat;
}

this.pickerDateTimeFormat = utils.normalizeDate(this.pickerDateTimeFormat);
this.pickerDateTimeFormat = utils.convertToMomentFormat(this.pickerDateTimeFormat);

if (this.dateFormat) {
this.inputDateFormat = this.dateFormat;
}

this.inputDateFormat = utils.normalizeDate(this.inputDateFormat);
this.outputDateFormat = utils.normalizeDate(this.outputDateFormat);
this.inputDateFormat = utils.convertToMomentFormat(this.inputDateFormat);
this.outputDateFormat = utils.convertToMomentFormat(this.outputDateFormat);

this.validationParams.dateFormat = this.outputDateFormat;
},

/**
* Converts PHP IntlFormatter format to moment format.
*
* @param {String} format - PHP format
* @returns {String} - moment compatible formatting
*/
convertToMomentFormat: function (format) {
var newFormat;

newFormat = format.replace(/yy|y/gi, 'YYYY'); // replace the year
newFormat = newFormat.replace(/dd|d/g, 'DD'); // replace the date
newFormat = newFormat.replace(/mm|m/gi, 'MM'); //replace the month

return newFormat;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ define([
'setDate',
moment(
observable(),
utils.normalizeDate(
utils.convertToMomentFormat(
options.dateFormat + (options.showsTime ? ' ' + options.timeFormat : '')
)
).toDate()
Expand Down
Loading

0 comments on commit 813fad8

Please sign in to comment.