Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ago? #55

Closed
curran opened this issue Feb 16, 2019 · 4 comments
Closed

Ago? #55

curran opened this issue Feb 16, 2019 · 4 comments

Comments

@curran
Copy link

curran commented Feb 16, 2019

I was just evaluating various "time ago" libraries, such as https://github.com/hustcc/timeago.js and https://github.com/nmn/react-timeago , and it occurred to me that a formatter using the ago format would probably be straightforward to construct using d3-time-format.

Might it be of interest to include an ago formatting method as part of d3-time-format?

Returning an update interval in ms would also be a useful counterpart, for updating the string.

@mbostock
Copy link
Member

mbostock commented Feb 16, 2019

I’m currently considering the long-term plan for this library.

JavaScript’s native support for localized date and time formatting has improved dramatically since D3 was first created (and pv.Format.time in Protovis before that). In particular, the fact that date.toLocaleString automatically uses the browser’s current locale is such a huge improvement (less en-US-centric) that I feel promoting d3-time-format’s continued use is harmful.

https://beta.observablehq.com/@mbostock/date-formatting

There is a standard for relative time format, Intl.RelativeTimeFormat:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat

It hasn’t made it to Edge and Safari yet, but Edge will eventually be Chromium, and Safari will hopefully come around. I expect therefore it would be better to encourage adoption of the standard and perhaps offer a polyfill than to compete with the proposed standard.

@mbostock
Copy link
Member

@curran
Copy link
Author

curran commented Feb 17, 2019

Excellent! Thank you for putting some time into this.

Thanks for the reference to https://github.com/catamphetamine/relative-time-format from your notebook, I had not seen that one.

@mbostock
Copy link
Member

I have no plans to expand the scope of this library to cover relative time formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants