React-dates: Custom function for weekDayFormat

Created on 21 Mar 2018  Â·  5Comments  Â·  Source: airbnb/react-dates

Hi there – awesome library!
There's one thing I'm missing though, could you please allow passing a function to weekDayFormat?
I would like to show the weekday header as M T W T F S S, which does not seem to be a valid date format (makes sense, as Sat & Sun are displayed identically).
Something like:

weekDayFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.func])

I'm happy to submit a PR with a solution if this is something you would support.

Most helpful comment

Can you reopen it? It's still a needed feature for me. Or did you manage to do it in some other way?

-- EDIT --

I managed to do it with a css workaround for now:

.DayPicker_weekHeader_li {
  visibility: hidden;
  font-size: 0;
}
.DayPicker_weekHeader_li::first-letter {
  visibility: visible;
  font-size: 18px;
}

All 5 comments

Also Tuesday and Thursday.

Can you elaborate on why you think it would be an acceptable user experience to have Tuesday/Thursday and Saturday/Sunday show duplicate headings? Typically this is considered a bad practice which is why Thursday is commonly referred to with "R" as a single letter.

Ah, yes, Tuesday and Thursday as well. 🙈
The header would just be there to indicate where the week starts, it's quite minor visually as well. I have no other explanation tbh, and agree that ux-wise it's better to have 2 letters.

I do have another use case for customising though, e.g. in Hungarian locale I have the day names all lower case, but I would want them uppercase, no matter the language. I realise I could do this with pure css, but then again, why not format it.

In any case, I'd like to be able to format it with a custom function, just as I am with displayFormat.

We had a PR for this.... did it get merged? Let me poke around.

@majapw thanks!
https://github.com/airbnb/react-dates/pull/650 is similar and was merged, but that only allows passing a string (e.g. of dd, ddd and dddd), not a function.

Can you reopen it? It's still a needed feature for me. Or did you manage to do it in some other way?

-- EDIT --

I managed to do it with a css workaround for now:

.DayPicker_weekHeader_li {
  visibility: hidden;
  font-size: 0;
}
.DayPicker_weekHeader_li::first-letter {
  visibility: visible;
  font-size: 18px;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Daniel15 picture Daniel15  Â·  3Comments

thomasdtucker picture thomasdtucker  Â·  3Comments

cemremengu picture cemremengu  Â·  3Comments

ekohanyi picture ekohanyi  Â·  3Comments

swaritkohli picture swaritkohli  Â·  3Comments