diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-08-26 23:54:17 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-08-26 23:54:17 +0300 |
commit | 8f5278eb443864910dd9c2131c992d71e3af2d20 (patch) | |
tree | d56d805fa010e4b10af7dec0ed359f218e859667 /src/lib/util.ts |
Big bang
Diffstat (limited to 'src/lib/util.ts')
-rw-r--r-- | src/lib/util.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/util.ts b/src/lib/util.ts new file mode 100644 index 0000000..a0734b9 --- /dev/null +++ b/src/lib/util.ts @@ -0,0 +1,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; +} |