This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Exhaustive checking is the concept of ensuring that all possibilities have | |
been covered when e.g. handling the different cases for values in an enum. | |
Below are some snippets to achieve this in Typescript. | |
*/ | |
enum Job { | |
Engineer = 'engineer', | |
KeyAccountManager = 'key-account-manager', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Webkit timestamp is the number of microseconds from "1st of Jan 1601" | |
// The magic number 11644473600 is the number of seconds between | |
// "1st of Jan 1601" and "1st of Jan 1970" | |
export const converWebkitTimestamp = (webkitTimestamp: number): Date => { | |
const dateInSeconds = Math.round(webkitTimestamp / 1000000) - 11644473600 | |
return new Date(dateInSeconds * 1000) | |
} |