Repository: cordova-plugin-globalization Updated Branches: refs/heads/master 8bc44ac14 -> 7a8dc01c9
Errors in weekdays fixed * getDateNames should return (Sun - Sat) in all locales * getFirstDayOfWeek should return 1 for Sunday and 2 for Monday * bunch of jsHint fixes Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/e8baaaa8 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/e8baaaa8 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/e8baaaa8 Branch: refs/heads/master Commit: e8baaaa8db58973c74ab44397a5c7e85ca8967dc Parents: 8bc44ac Author: Piotr Zalewa <[email protected]> Authored: Wed Oct 8 09:45:41 2014 +0200 Committer: Piotr Zalewa <[email protected]> Committed: Wed Oct 8 09:45:41 2014 +0200 ---------------------------------------------------------------------- src/firefoxos/GlobalizationProxy.js | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/e8baaaa8/src/firefoxos/GlobalizationProxy.js ---------------------------------------------------------------------- diff --git a/src/firefoxos/GlobalizationProxy.js b/src/firefoxos/GlobalizationProxy.js index 910ef6b..07d92dc 100644 --- a/src/firefoxos/GlobalizationProxy.js +++ b/src/firefoxos/GlobalizationProxy.js @@ -109,17 +109,17 @@ function dateToString(successCB, errorCB, params) { function _getStringFromDate(f, date, options) { var format = navigator.mozL10n.get('shortDateTimeFormat'); if (options) { - if (options.selector == 'date') { + if (options.selector === 'date') { return f.localeDateString(date); } - if (options.selector == 'time') { + if (options.selector === 'time') { return f.localeTimeString(date); } - if (options.formatLength != 'short') { + if (options.formatLength !== 'short') { format = navigator.mozL10n.get('dateTimeFormat'); return f.localeString(date, format); } - if (options.selector == 'time') { + if (options.selector === 'time') { return f.localeTimeString(date, format); } } @@ -137,12 +137,12 @@ function stringToDate(successCB, errorCB, params) { date = new Date(dateString); } catch(e) { console.log("Cordova, stringToDate, An error occurred " + e.message); - return errorCB(GlobalizationError( + return errorCB(new GlobalizationError( GlobalizationError.PARSING_ERROR, e.message)); } - if (!date || date == 'Invalid Date') { + if (!date || date === 'Invalid Date') { console.log("Cordova, stringToDate, Invalid Date: " + dateString); - return errorCB(GlobalizationError( + return errorCB(new GlobalizationError( GlobalizationError.PARSING_ERROR, 'Invalid Date (' + dateString + ')')); } @@ -158,10 +158,10 @@ function stringToDate(successCB, errorCB, params) { 'millisecond': date.getMilliseconds() }; if (options) { - if (options.selector == 'date') { + if (options.selector === 'date') { return successCB(dateObj); } - if (options.selector == 'time') { + if (options.selector === 'time') { return successCB(timeObj); } } @@ -181,24 +181,22 @@ function getDateNames(successCB, failureCB, params) { callIfL10nReady(function() { var version = 'long'; var item = 'month'; - var first = 0; var options = params[0].options; if (options) { - if (options.type == 'narrow') { + if (options.type === 'narrow') { version = 'short'; - } else if (options.type == 'genitive' && options.item == 'months') { + } else if (options.type === 'genitive' && options.item === 'months') { version = options.type; } - if (options.item == 'days') { + if (options.item === 'days') { item = 'weekday'; - first = parseInt(navigator.mozL10n.get('weekStartsOnMonday')); } } - var limit = (item == 'month') ? 11 : 6; + var limit = (item === 'month') ? 11 : 6; var arr = []; - for (var i = first; i <= first + limit; i++) { - arr.push(navigator.mozL10n.get(item + '-' + i % (limit + 1) + '-' + version)); + for (var i = 0; i <= limit; i++) { + arr.push(navigator.mozL10n.get(item + '-' + i + '-' + version)); } successCB({'value': arr}); }); @@ -223,7 +221,9 @@ function isDayLightSavingsTime(successCB, failureCB, params) { function getFirstDayOfWeek(successCB, failureCB) { callIfL10nReady(function() { var firstDay = navigator.mozL10n.get('weekStartsOnMonday'); - successCB({'value': parseInt(firstDay)}); + // Sunday: 1 + // Monday: 2 + successCB({'value': 1 + parseInt(firstDay)}); }); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
