Skip to content

web: bucketize durations under a minute#1581

Merged
landism merged 4 commits into
masterfrom
mlandis/ch2336/as-a-user-i-see-sidebar-timeago-in-1m-intervals
May 6, 2019
Merged

web: bucketize durations under a minute#1581
landism merged 4 commits into
masterfrom
mlandis/ch2336/as-a-user-i-see-sidebar-timeago-in-1m-intervals

Conversation

@landism

@landism landism commented May 3, 2019

Copy link
Copy Markdown
Member

A la the TUI

image

@landism
landism requested review from hyu and jazzdan May 3, 2019 19:05
Comment thread web/src/Sidebar.test.tsx
describe("sidebar", () => {
beforeEach(() => {
Date.now = jest.fn(() => 1482363367071)
Date.now = jest.fn(() => Date.UTC(2017, 11, 21, 15, 36, 7, 0))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to make this human-readable

Comment thread web/src/testdata.test.tsx

function oneResource(): any {
const ts = Date.now().toLocaleString()
const ts = Date.now().valueOf()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jazzdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Should we add a snapshot that renders a sidebar within these new time durations?

@landism
landism force-pushed the mlandis/ch2336/as-a-user-i-see-sidebar-timeago-in-1m-intervals branch from 123c891 to 8a2ef12 Compare May 3, 2019 20:09
@landism

landism commented May 3, 2019

Copy link
Copy Markdown
Member Author

Should we add a snapshot that renders a sidebar within these new time durations

done

@landism
landism merged commit 59de1db into master May 6, 2019
@landism
landism deleted the mlandis/ch2336/as-a-user-i-see-sidebar-timeago-in-1m-intervals branch May 6, 2019 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants