GithubHelp home page GithubHelp logo

Comments (7)

mbostock avatar mbostock commented on May 18, 2024

I have noticed that date.toLocaleString is extremely slow, but perhaps browser vendors haven’t realized that and will make performance improvements as it is adopted by web developers.

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

Since there is no standard for parsing dates (yet), it probably makes sense to retain part of this library as a D3 module that only implements parsing (not formatting). But I think it should be optional as most people should be using ISO 8601 to represent machine-readable dates and not using arbitrary localized formats in local time.

We also probably want a strict ECMAScript IEEE 8601 date parser in d3-time or somewhere central, and probably a shorthand formatter as well, since browser support for that is not quite where it should be and there is still an active TC39 proposal to standardize the behavior of Date.parse.

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

Here are the relevant bits from d3-dsv to parse and format ECMAScript dates strictly:

https://github.com/d3/d3-dsv/blob/ff2d09f943c2d19d0f0fa96f9b6a39c7431ca7e8/src/autoType.js#L9
https://github.com/d3/d3-dsv/blob/ff2d09f943c2d19d0f0fa96f9b6a39c7431ca7e8/src/dsv.js#L47

from d3-time-format.

curran avatar curran commented on May 18, 2024

FWIW, date.toLocaleString seems to have pretty good coverage - everything except Android webview.

image

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

Unfortunately date.toLocaleString is far too slow for many applications (e.g., when formatting thousands of dates for static tooltips). But I haven’t yet tested whether creating an Intl.DateTimeFormat instance would be faster. If it is, that may be a viable replacement for this library.

from d3-time-format.

curran avatar curran commented on May 18, 2024

A benchmark would be good to have on hand, so we could easily check if browser vendors make performance improvements. Is there an example you know of that demonstrates or measures the slowness?

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

I think this library still serves a purpose, at least as far as parsing goes, and it’s nice to have symmetry with formatting. Therefore closing this issue.

from d3-time-format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.