a fun bot for the hc slack
1// Helper function for pretty-printing time
2export const prettyPrintTime = (ms: number): string => {
3 const hours = Math.floor(ms / 3600000);
4 const minutes = Math.floor((ms % 3600000) / 60000);
5
6 if (hours > 0 && minutes > 5) {
7 return `${hours} hours and ${minutes} minutes`;
8 }
9 if (hours > 0) {
10 return `${hours} hours`;
11 }
12 if (minutes < 2) {
13 const seconds = Math.max(0, Math.round(ms / 1000));
14 return `${seconds} seconds`;
15 }
16 return `${minutes} minutes`;
17};
18
19// Helper function that generates the slack date format
20export const generateSlackDate = (endTime: Date): string => {
21 return `<!date^${Math.floor(endTime.getTime() / 1000)}^{time}|${endTime.toLocaleTimeString()}>`;
22};