-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
21 lines (18 loc) · 903 Bytes
/
Copy pathutil.js
File metadata and controls
21 lines (18 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember']
const ucwords = (string) => string.charAt(0).toUpperCase() + string.slice(1)
const datetimeStr = (utcStr) => {
const month = months[parseInt(utcStr.substr(4, 2)) - 1]
return {
datetime: utcStr.replace(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)$/, "$1-$2-$3, $4:$5:00"),
date: utcStr.replace(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)$/, `$3 ${month} $1`),
hour: utcStr.replace(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)$/, "$4:$5"),
}
}
const dateStr = (utcStr) => {
const month = months[parseInt(utcStr.substr(4, 2)) - 1]
return {
datetime: utcStr.replace(/^(\d{4})(\d\d)(\d\d)$/, "$1-$2-$3, 00:00:00"),
date: utcStr.replace(/^(\d{4})(\d\d)(\d\d)$/, `$3 ${month} $1`),
}
}
module.exports = { ucwords, datetimeStr, dateStr }