From e56c2b4812ec0c79c63e9849f9a2e5f700bd2714 Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Thu, 4 Sep 2014 15:47:48 -0300 Subject: [PATCH] (fix) Datepicker: Use Globalize 1.0.0 - Use format/parse generators --- ui/calendar.js | 33 ++++++++++----------------------- ui/datepicker.js | 15 +++------------ 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/ui/calendar.js b/ui/calendar.js index da8604458..b773281ab 100644 --- a/ui/calendar.js +++ b/ui/calendar.js @@ -177,35 +177,22 @@ return $.widget( "ui.calendar", { }, _setLocale: function( locale ) { - var globalize = new Globalize( locale ); - - this._format = function( date ) { - return globalize.formatDate( date, { date: "short" } ); - }; - - this._parse = function( stringDate ) { - return globalize.parseDate( stringDate, { date: "short" } ); - }; - + var globalize = new Globalize( locale ), + weekdayShortFormatter = globalize.dateFormatter({ pattern: "EEEEEE" }), + weekdayNarrowFormatter = globalize.dateFormatter({ pattern: "EEEEE" }); + this._format = globalize.dateFormatter({ date: "short" }); + this._parse = globalize.dateParser({ date: "short" }); this._calendarDateOptions = { firstDay: globalize.cldr.supplemental.weekData.firstDay(), formatWeekdayShort: function( date ) { // Return the short weekday if its length is < 3. Otherwise, its narrow form. - var shortWeekday = globalize.formatDate( date, { pattern: "EEEEEE" } ); - return shortWeekday.length > 3 ? - globalize.formatDate( date, { pattern: "EEEEE" } ) : - shortWeekday; - }, - formatWeekdayFull: function( date ) { - return globalize.formatDate( date, { pattern: "EEEE" } ); + var shortWeekday = weekdayShortFormatter( date ); + return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday; }, - formatMonth: function( date ) { - return globalize.formatDate( date, { pattern: "MMMM" } ); - }, - formatWeekOfYear: function( date ) { - return globalize.formatDate( date, { pattern: "w" } ); - }, + formatWeekdayFull: globalize.dateFormatter({ pattern: "EEEE" }), + formatMonth: globalize.dateFormatter({ pattern: "MMMM" }), + formatWeekOfYear: globalize.dateFormatter({ pattern: "w" }), parse: this._parse }; }, diff --git a/ui/datepicker.js b/ui/datepicker.js index b95d5a4f1..813978215 100644 --- a/ui/datepicker.js +++ b/ui/datepicker.js @@ -283,18 +283,9 @@ var widget = $.widget( "ui.datepicker", { _setLocale: function( locale ) { var globalize = new Globalize( locale ); - - this._format = function( date ) { - return globalize.formatDate( date, { date: "short" } ); - }; - - this._parse = function( stringDate ) { - return globalize.parseDate( stringDate, { date: "short" } ); - }; - - this._parseYMD = function( stringDate ) { - return globalize.parseDate( stringDate, { pattern: "yyyy-MM-dd" } ); - }; + this._format = globalize.dateFormatter({ date: "short" }); + this._parse = globalize.dateParser({ date: "short" }); + this._parseYMD = globalize.dateParser({ pattern: "yyyy-MM-dd" }); }, _buildPosition: function() { -- 2.39.5