web: bucketize durations under a minute#1581
Conversation
| describe("sidebar", () => { | ||
| beforeEach(() => { | ||
| Date.now = jest.fn(() => 1482363367071) | ||
| Date.now = jest.fn(() => Date.UTC(2017, 11, 21, 15, 36, 7, 0)) |
There was a problem hiding this comment.
just to make this human-readable
|
|
||
| function oneResource(): any { | ||
| const ts = Date.now().toLocaleString() | ||
| const ts = Date.now().valueOf() |
There was a problem hiding this comment.
it turns out .toLocaleString is inherited from number, and returns a human-readable formatting of the number of milliseconds since epoch, which looks like 1,482,363,367,071.
timeago passes that to Date.parse, which rejects it because of the commas, and then kind of assumes that since there are at least three non-contiguous numbers (i.e., /\d+/ in the string), the second one must be a month, which means it needs to have one subtracted to make it 0-based, and then reconcatenates them (code), which is why the old snapshot timestamp was 1942 and timeago rendered it as 75yr
jazzdan
left a comment
There was a problem hiding this comment.
Nice! Should we add a snapshot that renders a sidebar within these new time durations?
123c891 to
8a2ef12
Compare
done |
A la the TUI