I tried a lot about how to use formatMonthYear, formatShortWeekday? But couldn't write code properly. I need to use the single letter week names. Please need help
formatShortWeekday = () => {
value => ['S', 'M', 'T', 'W', 'T', 'F', 'S'][value.getDay()]
}
render() {
return (
<CalendarInput
value='' // Need to implement
returnValue="range"
calendarType="US"
className={classes.calendar}
onChange={() => {
// Need to implement
}}
formatShortWeekday={this.formatShortWeekday}
/>
);
}
Getting errors, I believe there is some syntax mistake.
I followed this issue https://github.com/wojtekmaj/react-calendar/issues/34 but not cleared how to use any of these formatDate functions.
Please help.
As documentation states, formatShortWeekday gets two arguments: locale, date. You need to .getDay() on date that is given as an argument, and it should work just fine.
formatShortWeekday = (locale, date) => ['S', 'M', 'T', 'W', 'T', 'F', 'S'][date.getDay()]
And how do you do it locale-dependent? I'm trying to use the exact example from the documentation
(locale, date) => formatDate(date, 'dd')
but I keep getting the following error:
Calendar.js:94 Uncaught TypeError: Object(...) is not a function
Most helpful comment
As documentation states,
formatShortWeekdaygets two arguments:locale,date. You need to.getDay()ondatethat is given as an argument, and it should work just fine.