Skip to content

Commit 813fad8

Browse files
author
Joan He
authored
Merge pull request #682 from magento-fearless-kiwis/FearlessKiwis-MAGETWO-62262
Fearless kiwis magetwo 62262
2 parents 383d18a + c7e851c commit 813fad8

File tree

6 files changed

+685
-667
lines changed

6 files changed

+685
-667
lines changed

app/code/Magento/Ui/view/base/web/js/form/element/date.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,38 +167,22 @@ define([
167167
prepareDateTimeFormats: function () {
168168
this.pickerDateTimeFormat = this.options.dateFormat;
169169
this.momentFormat = this.options.dateFormat ?
170-
this.convertToMomentFormat(this.options.dateFormat) : this.momentFormat;
170+
utils.convertToMomentFormat(this.options.dateFormat) : this.momentFormat;
171171

172172
if (this.options.showsTime) {
173173
this.pickerDateTimeFormat += ' ' + this.options.timeFormat;
174174
}
175175

176-
this.pickerDateTimeFormat = utils.normalizeDate(this.pickerDateTimeFormat);
176+
this.pickerDateTimeFormat = utils.convertToMomentFormat(this.pickerDateTimeFormat);
177177

178178
if (this.dateFormat) {
179179
this.inputDateFormat = this.dateFormat;
180180
}
181181

182-
this.inputDateFormat = utils.normalizeDate(this.inputDateFormat);
183-
this.outputDateFormat = utils.normalizeDate(this.outputDateFormat);
182+
this.inputDateFormat = utils.convertToMomentFormat(this.inputDateFormat);
183+
this.outputDateFormat = utils.convertToMomentFormat(this.outputDateFormat);
184184

185185
this.validationParams.dateFormat = this.outputDateFormat;
186-
},
187-
188-
/**
189-
* Converts PHP IntlFormatter format to moment format.
190-
*
191-
* @param {String} format - PHP format
192-
* @returns {String} - moment compatible formatting
193-
*/
194-
convertToMomentFormat: function (format) {
195-
var newFormat;
196-
197-
newFormat = format.replace(/yy|y/gi, 'YYYY'); // replace the year
198-
newFormat = newFormat.replace(/dd|d/g, 'DD'); // replace the date
199-
newFormat = newFormat.replace(/mm|m/gi, 'MM'); //replace the month
200-
201-
return newFormat;
202186
}
203187
});
204188
});

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ define([
5353
'setDate',
5454
moment(
5555
observable(),
56-
utils.normalizeDate(
56+
utils.convertToMomentFormat(
5757
options.dateFormat + (options.showsTime ? ' ' + options.timeFormat : '')
5858
)
5959
).toDate()

0 commit comments

Comments
 (0)