-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
25 lines (22 loc) · 734 Bytes
/
Copy pathutils.js
File metadata and controls
25 lines (22 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* Get formatted date
* @param {string} timezone
* @param {integer} daysOffset
*/
function getFormattedDate(timezone, daysOffset = 0) {
const now = new Date();
if (daysOffset === 0) {
const year = now.getYear() + 1900;
const month = now.getMonth() + 1;
const day = now.getDate();
return `${year}-${month < 10 ? `0${month}` : month}-${day < 10 ? `0${day}` : day}`;
}
const date = new Date(now.setDate(now.getDate() + daysOffset));
const year = date.getYear() + 1900;
const month = date.getMonth() + 1;
const day = date.getDate();
return `${year}-${month < 10 ? `0${month}` : month}-${day < 10 ? `0${day}` : day}`;
}
module.exports = {
getFormattedDate
};