Comments (6)
Okay, I thought about it more, and I’ll bump this repo to 2.0. Thanks for the suggestion.
from d3-time-format.
Sounds like a bug in the port from 3.x?
from d3-time-format.
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.
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.
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.
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
.
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)
- Parser returned from timeParse returns a different time zone HOT 1
- Time formats in d3
- Missing Semester HOT 4
- Cannot require() starting with version 4 HOT 3
- How do I get at the locales? HOT 1
- Doc: %S range HOT 3
- %Z behavior does not match strftime HOT 2
- timezone without 00, e.g +08 , instead of +0800? HOT 1
- d3.timeFormat("%Y-%U") return value is inconsistent with python 3 strftime for "2023-01-01" HOT 6
- numeric month without leading 0 HOT 1
- formatUTCWeekNumberISO and formatWeekNumberISO return incorrect results at edge of the year HOT 4
- Year support for "10000" HOT 2
- JSON of locale need no-periods attribute HOT 3
- Parsing Negative Unix Values Fail HOT 1
- remove dev dependency on d3-queue
- Invalid string parses but results in unexpected date HOT 1
- Full ISO 8601 support?
- ISO week year (%g and %G) parsing and formatting is inconsistent.
- ch
- Locale files not exported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-time-format.