Created
October 29, 2014 23:01
-
-
Save viniciusdaniel/c4775e9d53caa64ff467 to your computer and use it in GitHub Desktop.
D3.js localize pt-BR for time and number formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Configuração de localização em Português do Brasil(PT-BR) para o D3.js realizar formatação tempo e números | |
* Mais detalhes conferir a documentação: https://github.com/mbostock/d3/wiki/Time-Formatting | |
*/ | |
var localized = d3.locale({ | |
"decimal": ",", | |
"thousands": ".", | |
"grouping": [3], | |
"currency": ["R$", ""], | |
"dateTime": "%d/%m/%Y %H:%M:%S", | |
"date": "%d/%m/%Y", | |
"time": "%H:%M:%S", | |
"periods": ["AM", "PM"], | |
"days": ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"], | |
"shortDays": ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"], | |
"months": ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"], | |
"shortMonths": ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"] | |
}); | |
var date = new Date(1986, 1, 13); | |
var formatter = localized.timeFormat("%A, %d %B %Y"); | |
console.log(formatter(date)); // "Quinta, 13 Fevereiro 1986" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment