GithubHelp home page GithubHelp logo

Comments (6)

mbostock avatar mbostock commented on May 18, 2024 1

Okay, I thought about it more, and I’ll bump this repo to 2.0. Thanks for the suggestion.

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

Sounds like a bug in the port from 3.x?

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

Not a bug, strictly speaking. These defaults actually come from the behavior of the date command on OS X by default:

$ date +%c
Wed Jun 22 15:33:14 2016
$ date +%x
06/22/2016
$ date +%X
15:33:19

But, I’m not sure it has to be that way. It would probably make more sense to mimic date.toLocaleString, date.toLocaleDateString and date.toLocaleTimeString. These vary a bit across browsers, but in Chrome:

(new Date).toLocaleString(); // "6/22/2016, 3:34:57 PM"
(new Date).toLocaleDateString(); // "6/22/2016"
(new Date).toLocaleTimeString(); // "3:34:57 PM"

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

Given that I’ve already pushed a 1.0 release of this module and the behavior is consistent with D3 3.x (and date), I’m not going to change this now—it should probably be considered a non-backwards-compatible change. If you want a 12-hour time representation, then I recommend using %I:%M:%S %p explicitly and not relying on the en-US locale.

from d3-time-format.

rahulpowar avatar rahulpowar commented on May 18, 2024

Interestingly enough if you change your region on OS-X via Settings -> Language & Region it defaults to 12h for the US which align with Windows (as per http://travel.stackexchange.com/questions/34950/which-large-countries-use-12-hour-time-format-am-pm) and at least Chrome as you noted.

Understood r.e. the major version though given that D3v4 as a whole is still Alpha worth considering further?

Unfortunately I can't fix the format to the string as I am working on a layer that defaults to the user's culture to format dates/numbers automatically. I expect I would fork this and align them to Chrome so that the output plays nicely with the native localisation. Would you be open to breaking out the JSON configuration files into a another d3 module for d3-format and d3-time-format? It would make maintaining a parallel fork a lot tidier for me and any one else who has specific requirements. They also seem currently optional to these modules so maybe it makes sense in general?

from d3-time-format.

mbostock avatar mbostock commented on May 18, 2024

You don’t need to fork this repository simply to change the default locale or to load different locales.

Use d3.formatDefaultLocale and d3.timeFormatDefaultLocale to redefine the default locale.

For the non-default locales, simply load your own locale definitions rather than the ones in this repository. The non-default locales aren’t included in the code, so it’s not necessary to fork the code to change their definition. The locales are published to npm, but you can load them from anywhere.

Changing my region had no effect on the date command, but I do see that the OS X (er, macOS) defaults do seem more reasonable than date.

screen shot 2016-06-23 at 7 57 05 am

I could make this change to D3 4.0 since it is not yet released, but it would require bumping this repository to 2.0. I’m still thinking about it.

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.