-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.ts
41 lines (36 loc) · 1.08 KB
/
index.ts
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
41
import moment from 'moment';
import common_pb from '../api/common_pb';
/*
Converts inputted string to sentence case
Args:
theString: Inputted string to be converted
*/
const toSentenceCase = (theString) => {
const newString = theString.toLowerCase().replace(
// eslint-disable-next-line
/(^\s*\w|[\.\!\?]\s*\w)/g,
(c) => {
return c.toUpperCase();
}
);
return newString;
};
const getDate = (timing: common_pb.Timing | undefined) => {
const startTiming =
(timing &&
timing.getStartTime() &&
timing.getStartTime().getSeconds()) ||
0;
const startTime = moment.unix(startTiming);
return startTime.format(`YYYY-MM-DD, hh:mm A`);
};
const flakyTestHeaderDate = (timing: common_pb.Timing | undefined) => {
const startTiming =
(timing &&
timing.getStartTime() &&
timing.getStartTime().getSeconds()) ||
0;
const startTime = moment.unix(startTiming);
return startTime.format(`MM/DD hh:mm`);
};
export { toSentenceCase, getDate, flakyTestHeaderDate };