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
| // from https://twitter.com/Steve8708/status/1504131981444980739 | |
| // simplified to a function body of 10 tidy lines | |
| // no loop needed, no 2d array of 3-tuples needed | |
| // just 2 arrays, a findIndex call, and some indexing :) | |
| export function getRelativeTimeString( | |
| date: Date | number, | |
| lang = "en" | |
| ): string { | |
| const time = typeof date === "number" ? date : date.getTime(); |