-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.js
40 lines (33 loc) · 839 Bytes
/
helpers.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const formatLaunchWindow = (isoDate1, isoDate2, status) => {
if (status === 'TBD') {
return 'TBD';
}
const options = {
hour: '2-digit',
minute: '2-digit',
hour12: false,
};
const windowStart = new Date(isoDate1);
const windowEnd = new Date(isoDate2);
return `${windowStart.toLocaleTimeString(
'en-US',
options
)} - ${windowEnd.toLocaleTimeString('en-US', options)}`;
};
const formatDate = (isoDate, status) => {
if (status === 'TBD') {
return 'TBD';
}
const options = {
weekday: 'short',
month: 'short',
day: '2-digit',
};
const date = new Date(isoDate);
return date.toLocaleDateString('en-us', options);
};
const getLocationIds = (locations) => {
return locations.length > 0
? locations.map((location) => `&location__ids=${location}`).join('')
: '';
};