Skip to content

Commit a8d5e80

Browse files
committed
(fix) Datepicker: Use Globalize 1.0.0
- Use format/parse generators;
1 parent 1d8ef5a commit a8d5e80

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
@@ -158,35 +158,22 @@ return $.widget( "ui.calendar", {
158158
},
159159

160160
_setLocale: function( locale ) {
161-
var globalize = new Globalize( locale );
162-
163-
this._format = function( date ) {
164-
return globalize.formatDate( date, { date: "short" } );
165-
};
166-
167-
this._parse = function( stringDate ) {
168-
return globalize.parseDate( stringDate, { date: "short" } );
169-
};
170-
161+
var globalize = new Globalize( locale ),
162+
weekdayShortFormatter = globalize.dateFormatter({ pattern: "EEEEEE" }),
163+
weekdayNarrowFormatter = globalize.dateFormatter({ pattern: "EEEEE" });
164+
this._format = globalize.dateFormatter({ date: "short" });
165+
this._parse = globalize.dateParser({ date: "short" });
171166
this._calendarDateOptions = {
172167
firstDay: globalize.cldr.supplemental.weekData.firstDay(),
173168
formatWeekdayShort: function( date ) {
174169

175170
// Return the short weekday if its length is < 3. Otherwise, its narrow form.
176-
var shortWeekday = globalize.formatDate( date, { pattern: "EEEEEE" } );
177-
return shortWeekday.length > 3 ?
178-
globalize.formatDate( date, { pattern: "EEEEE" } ) :
179-
shortWeekday;
180-
},
181-
formatWeekdayFull: function( date ) {
182-
return globalize.formatDate( date, { pattern: "EEEE" } );
183-
},
184-
formatMonth: function( date ) {
185-
return globalize.formatDate( date, { pattern: "MMMM" } );
186-
},
187-
formatWeekOfYear: function( date ) {
188-
return globalize.formatDate( date, { pattern: "w" } );
171+
var shortWeekday = weekdayShortFormatter( date );
172+
return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday;
189173
},
174+
formatWeekdayFull: globalize.dateFormatter({ pattern: "EEEE" }),
175+
formatMonth: globalize.dateFormatter({ pattern: "MMMM" }),
176+
formatWeekOfYear: globalize.dateFormatter({ pattern: "w" }),
190177
parse: this._parse
191178
};
192179
},

ui/datepicker.js

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

275275
_setLocale: function( locale ) {
276276
var globalize = new Globalize( locale );
277-
278-
this._format = function( date ) {
279-
return globalize.formatDate( date, { date: "short" } );
280-
};
281-
282-
this._parse = function( stringDate ) {
283-
return globalize.parseDate( stringDate, { date: "short" } );
284-
};
285-
286-
this._parseYMD = function( stringDate ) {
287-
return globalize.parseDate( stringDate, { pattern: "yyyy-MM-dd" } );
288-
};
277+
this._format = globalize.dateFormatter({ date: "short" });
278+
this._parse = globalize.dateParser({ date: "short" });
279+
this._parseYMD = globalize.dateParser({ pattern: "yyyy-MM-dd" });
289280
},
290281

291282
_buildPosition: function() {

0 commit comments

Comments
 (0)