Skip to content

Commit

Permalink
warn when trying to use a non-existent locale
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonjs committed Dec 28, 2016
1 parent 1e41e85 commit 335ef2e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions strftime.js
Expand Up @@ -239,9 +239,7 @@
var _deprecationWarnings = {};
function deprecationWarning(name, instead) {
if (!_deprecationWarnings[name]) {
if (typeof console !== 'undefined' && typeof console.warn == 'function') {
console.warn("[WARNING] " + name + " is deprecated and will be removed in version 1.0. Instead, use `" + instead + "`.");
}
warn("[WARNING] " + name + " is deprecated and will be removed in version 1.0. Instead, use `" + instead + "`.");
_deprecationWarnings[name] = true;
}
}
Expand Down Expand Up @@ -414,9 +412,7 @@
// ':'
else if (currentCharCode === 58) {
if (extendedTZ) {
if (typeof console !== 'undefined' && typeof console.warn == 'function') {
console.warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime");
}
warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime");
}
extendedTZ = true;
continue;
Expand Down Expand Up @@ -739,6 +735,10 @@

strftime.localizeByIdentifier = function(localeIdentifier) {
var locale = Locales[localeIdentifier];
if (!locale) {
warn('[WARNING] No locale found with identifier "' + localeIdentifier + '".');
return strftime;
}
return strftime.localize(locale);
};

Expand Down Expand Up @@ -847,4 +847,10 @@
return (date.getTimezoneOffset() || 0) * 60000;
}

function warn(message) {
if (typeof console !== 'undefined' && typeof console.warn == 'function') {
console.warn(message)
}
}

}());

0 comments on commit 335ef2e

Please sign in to comment.