15 lines
422 B
JavaScript
15 lines
422 B
JavaScript
function localDate(date = new Date()) {
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
const day = String(date.getDate()).padStart(2, "0");
|
|
return `${year}-${month}-${day}`;
|
|
}
|
|
|
|
function shiftDate(value, days) {
|
|
const date = new Date(`${value}T12:00:00`);
|
|
date.setDate(date.getDate() + days);
|
|
return localDate(date);
|
|
}
|
|
|
|
module.exports = { localDate, shiftDate };
|