mirror of
https://github.com/samsonjs/strftime.git
synced 2026-04-26 14:47:43 +00:00
warn when trying to use a non-existent locale
This commit is contained in:
parent
1e41e85146
commit
335ef2ebe8
1 changed files with 12 additions and 6 deletions
18
strftime.js
18
strftime.js
|
|
@ -239,9 +239,7 @@
|
||||||
var _deprecationWarnings = {};
|
var _deprecationWarnings = {};
|
||||||
function deprecationWarning(name, instead) {
|
function deprecationWarning(name, instead) {
|
||||||
if (!_deprecationWarnings[name]) {
|
if (!_deprecationWarnings[name]) {
|
||||||
if (typeof console !== 'undefined' && typeof console.warn == 'function') {
|
warn("[WARNING] " + name + " is deprecated and will be removed in version 1.0. Instead, use `" + instead + "`.");
|
||||||
console.warn("[WARNING] " + name + " is deprecated and will be removed in version 1.0. Instead, use `" + instead + "`.");
|
|
||||||
}
|
|
||||||
_deprecationWarnings[name] = true;
|
_deprecationWarnings[name] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -414,9 +412,7 @@
|
||||||
// ':'
|
// ':'
|
||||||
else if (currentCharCode === 58) {
|
else if (currentCharCode === 58) {
|
||||||
if (extendedTZ) {
|
if (extendedTZ) {
|
||||||
if (typeof console !== 'undefined' && typeof console.warn == 'function') {
|
warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime");
|
||||||
console.warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
extendedTZ = true;
|
extendedTZ = true;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -739,6 +735,10 @@
|
||||||
|
|
||||||
strftime.localizeByIdentifier = function(localeIdentifier) {
|
strftime.localizeByIdentifier = function(localeIdentifier) {
|
||||||
var locale = Locales[localeIdentifier];
|
var locale = Locales[localeIdentifier];
|
||||||
|
if (!locale) {
|
||||||
|
warn('[WARNING] No locale found with identifier "' + localeIdentifier + '".');
|
||||||
|
return strftime;
|
||||||
|
}
|
||||||
return strftime.localize(locale);
|
return strftime.localize(locale);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -847,4 +847,10 @@
|
||||||
return (date.getTimezoneOffset() || 0) * 60000;
|
return (date.getTimezoneOffset() || 0) * 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function warn(message) {
|
||||||
|
if (typeof console !== 'undefined' && typeof console.warn == 'function') {
|
||||||
|
console.warn(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue