Git Product home page Git Product logo

Comments (9)

mbostock avatar mbostock commented on July 24, 2024

A reduction of this issue (requires switching to Brasilia Standard Time):

date = new Date("2017-10-08T03:00:00.000Z") // Date 2017-10-08T03:00:00.000Z
d3.timeWeek(date) // Date 2017-10-08T03:00:00.000Z
d3.timeWeek.offset(date, 1) // Date 2017-10-15T02:00:00.000Z
d3.timeWeek(d3.timeWeek.offset(date, 1)) // Date 2017-10-08T03:00:00.000Z

from d3-time.

mbostock avatar mbostock commented on July 24, 2024

Actually, it’s even worse in that d3.timeWeek is not idempotent:

date = new Date("2017-10-15T03:00:00.000Z") // Date 2017-10-15T03:00:00.000Z
d3.timeWeek(date) // Date 2017-10-15T02:00:00.000Z
d3.timeWeek(d3.timeWeek(date)) // Date 2017-10-08T03:00:00.000Z

from d3-time.

mbostock avatar mbostock commented on July 24, 2024

In vanilla JavaScript (Firefox):

date = new Date("2017-10-15T03:00:00.000Z") // Date 2017-10-15T03:00:00.000Z
date.setHours(0, 0, 0, 0) // Date 2017-10-15T02:00:00.000Z
date.setHours(0, 0, 0, 0) // Date 2017-10-14T03:00:00.000Z

Whereas in Chrome:

date = new Date("2017-10-15T03:00:00.000Z") // Date 2017-10-15T03:00:00.000Z
date.setHours(0, 0, 0, 0) // Date 2017-10-15T03:00:00.000Z
date.setHours(0, 0, 0, 0) // Date 2017-10-15T03:00:00.000Z

So in other words, calling date.setHours in Firefox is changing the date from the 15th to the 14th.

from d3-time.

mbostock avatar mbostock commented on July 24, 2024

(d3.timeDay is also not idempotent in Firefox, for the same reasons.)

from d3-time.

mbostock avatar mbostock commented on July 24, 2024

I’m not sure it’s feasible to return the correct result in Firefox; in general, D3 is not a compatibility layer, so I rarely try to workaround a bug in date.setHours (and I think this counts as a bug… although perhaps I am misreading the spec). That said, if there’s a reasonably simple workaround, I’d be amenable to using it—I just can’t think of one immediately.

I’d also like to guarantee that interval.range can’t go into an infinite loop, but I think that would still mean that Firefox would have incorrect results. I’ll change this issue title accordingly.

from d3-time.

brunobg avatar brunobg commented on July 24, 2024

Any plans to make a new release soon with this patch?

from d3-time.

mbostock avatar mbostock commented on July 24, 2024

Thanks for the reminder. Will try to do this soon…

from d3-time.

martgnz avatar martgnz commented on July 24, 2024

Is there any update on this? We are blocked on releasing a project as this is still a problem with Firefox 57. Thank you!

from d3-time.

mbostock avatar mbostock commented on July 24, 2024

Will try today. Thanks for the reminder.

from d3-time.

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.