chore: replace deprecated String.prototype.substr()

.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
pull/21757/head
Tobias Speicher 2022-03-21 10:10:06 +01:00
parent 473ef53f93
commit 6d2f879e05
No known key found for this signature in database
GPG Key ID: 2CF824BD810C3BDB
1 changed files with 4 additions and 4 deletions

View File

@ -49,14 +49,14 @@
function shorten(arr, sLen) { function shorten(arr, sLen) {
var newArr = []; var newArr = [];
for (var i = 0, len = arr.length; i < len; i++) { for (var i = 0, len = arr.length; i < len; i++) {
newArr.push(arr[i].substr(0, sLen)); newArr.push(arr[i].slice(0, sLen));
} }
return newArr; return newArr;
} }
function monthUpdate(arrName) { function monthUpdate(arrName) {
return function (d, v, i18n) { return function (d, v, i18n) {
var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase()); var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.slice(1).toLowerCase());
if (~index) { if (~index) {
d.month = index; d.month = index;
} }
@ -122,7 +122,7 @@
return i18n.monthNames[dateObj.getMonth()]; return i18n.monthNames[dateObj.getMonth()];
}, },
yy: function(dateObj) { yy: function(dateObj) {
return pad(String(dateObj.getFullYear()), 4).substr(2); return pad(String(dateObj.getFullYear()), 4).slice(2);
}, },
yyyy: function(dateObj) { yyyy: function(dateObj) {
return pad(dateObj.getFullYear(), 4); return pad(dateObj.getFullYear(), 4);
@ -183,7 +183,7 @@
d.month = v - 1; d.month = v - 1;
}], }],
yy: [twoDigits, function (d, v) { yy: [twoDigits, function (d, v) {
var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2); var da = new Date(), cent = +('' + da.getFullYear()).slice(0, 2);
d.year = '' + (v > 68 ? cent - 1 : cent) + v; d.year = '' + (v > 68 ? cent - 1 : cent) + v;
}], }],
h: [twoDigits, function (d, v) { h: [twoDigits, function (d, v) {