Merge pull request #2170 from SergioCrisostomo/use-locale-formated-year-month

Correct month calculation and add specs for date-picker labels
This commit is contained in:
Aresn 2017-10-23 04:22:44 -05:00 committed by GitHub
commit b92a1b5c99
3 changed files with 68 additions and 14 deletions

View file

@ -67,7 +67,7 @@ export const formatDateLabels = (function() {
Formats:
yyyy - 4 digit year
m - month, numeric, 1 - 12
m - month, numeric, 01 - 12
mm - month, numeric, 01 - 12
mmm - month, 3 letters, as in `toLocaleDateString`
Mmm - month, 3 letters, capitalize the return from `toLocaleDateString`
mmmm - month, full name, as in `toLocaleDateString`
@ -76,8 +76,8 @@ export const formatDateLabels = (function() {
const formats = {
yyyy: date => date.getFullYear(),
m: date => date.getMonth(),
mm: date => ('0' + date.getMonth()).slice(-2),
m: date => date.getMonth() + 1,
mm: date => ('0' + (date.getMonth() + 1)).slice(-2),
mmm: (date, locale) => {
const monthName = date.toLocaleDateString(locale, {
month: 'long'