-
Notifications
You must be signed in to change notification settings - Fork 100
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Comments
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. |
Notebook for tinkering: https://beta.observablehq.com/@mbostock/relative-time-formatting |
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. |
I have no plans to expand the scope of this library to cover relative time formatting. |
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.
The text was updated successfully, but these errors were encountered: