agile-se1 / bit-web

Found shorthand type coercions JS-0066
Anti-pattern
Minor
5 months ago5 months old
use String(d.getDate()) instead
153    if (!date) return '';
154    const d = new Date(date),
155        month = '' + (d.getMonth() + 1),
156        day = '' + d.getDate(),157        year = d.getFullYear();
158
159    return [pad(day, 2), pad(month, 2), year].join('.');
use String(d.getMonth() + 1) instead
152function formatDate(date: Date) {
153    if (!date) return '';
154    const d = new Date(date),
155        month = '' + (d.getMonth() + 1),156        day = '' + d.getDate(),
157        year = d.getFullYear();
158
144);
145
146function pad(num: string, size: number): string {
147    let s = num + "";148    while (s.length < size) s = "0" + s;
149    return s;
150}