Skip to content

Commit e56c2b4

Browse files
rxaviersfnagel
authored andcommitted
(fix) Datepicker: Use Globalize 1.0.0
- Use format/parse generators
1 parent 7f432ed commit e56c2b4

File tree

2 files changed

+13
-35
lines changed

2 files changed

+13
-35
lines changed

ui/calendar.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,35 +177,22 @@ return $.widget( "ui.calendar", {
177177
},
178178

179179
_setLocale: function( locale ) {
180-
var globalize = new Globalize( locale );
181-
182-
this._format = function( date ) {
183-
return globalize.formatDate( date, { date: "short" } );
184-
};
185-
186-
this._parse = function( stringDate ) {
187-
return globalize.parseDate( stringDate, { date: "short" } );
188-
};
189-
180+
var globalize = new Globalize( locale ),
181+
weekdayShortFormatter = globalize.dateFormatter({ pattern: "EEEEEE" }),
182+
weekdayNarrowFormatter = globalize.dateFormatter({ pattern: "EEEEE" });
183+
this._format = globalize.dateFormatter({ date: "short" });
184+
this._parse = globalize.dateParser({ date: "short" });
190185
this._calendarDateOptions = {
191186
firstDay: globalize.cldr.supplemental.weekData.firstDay(),
192187
formatWeekdayShort: function( date ) {
193188

194189
// Return the short weekday if its length is < 3. Otherwise, its narrow form.
195-
var shortWeekday = globalize.formatDate( date, { pattern: "EEEEEE" } );
196-
return shortWeekday.length > 3 ?
197-
globalize.formatDate( date, { pattern: "EEEEE" } ) :
198-
shortWeekday;
199-
},
200-
formatWeekdayFull: function( date ) {
201-
return globalize.formatDate( date, { pattern: "EEEE" } );
190+
var shortWeekday = weekdayShortFormatter( date );
191+
return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday;
202192
},
203-
formatMonth: function( date ) {
204-
return globalize.formatDate( date, { pattern: "MMMM" } );
205-
},
206-
formatWeekOfYear: function( date ) {
207-
return globalize.formatDate( date, { pattern: "w" } );
208-
},
193+
formatWeekdayFull: globalize.dateFormatter({ pattern: "EEEE" }),
194+
formatMonth: globalize.dateFormatter({ pattern: "MMMM" }),
195+
formatWeekOfYear: globalize.dateFormatter({ pattern: "w" }),
209196
parse: this._parse
210197
};
211198
},

ui/datepicker.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,9 @@ var widget = $.widget( "ui.datepicker", {
283283

284284
_setLocale: function( locale ) {
285285
var globalize = new Globalize( locale );
286-
287-
this._format = function( date ) {
288-
return globalize.formatDate( date, { date: "short" } );
289-
};
290-
291-
this._parse = function( stringDate ) {
292-
return globalize.parseDate( stringDate, { date: "short" } );
293-
};
294-
295-
this._parseYMD = function( stringDate ) {
296-
return globalize.parseDate( stringDate, { pattern: "yyyy-MM-dd" } );
297-
};
286+
this._format = globalize.dateFormatter({ date: "short" });
287+
this._parse = globalize.dateParser({ date: "short" });
288+
this._parseYMD = globalize.dateParser({ pattern: "yyyy-MM-dd" });
298289
},
299290

300291
_buildPosition: function() {

0 commit comments

Comments
 (0)