aboutsummaryrefslogtreecommitdiff
path: root/src/lib/util.ts
blob: b6dd442e72a49240bdec71de1082f3888b2883de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export const creatorColor = (creatorid: string) => {
  let parts = creatorid.split('-')
  let ints = parts.map(function(d) { return parseInt(d,16) })
  let code = ints[0]

  let blue = (code >> 16) & 31;
  let green = (code >> 21) & 31;
  let red = (code >> 27) & 31;
  let foreColor = `border:5px solid rgb(${red << 3}, ${green << 3}, ${blue << 3});`;
  return foreColor;
};

export function formatTime(timestamp: number): string
{
  let date = new Date(timestamp);
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();
  let time = date.toTimeString().split(' ')[0];
  let formattedTime = `${time}, ${day}/${month}/${year}`

  return formattedTime;
}