简体   繁体   中英

How to fix date format in react-calendar without changing weekday name format in ja locale?

I'm using react-calendar library and cannnot fix code anymore.

When locale is 'ja', it returns dates with 'XX日'.

I'm using locale 'ja', and I want to fix these dates to "XX".

I tried to change locale 'en' to fix 'XX日' to 'XX'. It successed. But weekday name also changed "Sun, Mon, Thu...".

I want to fix 'XX日' without changing weekday names '日, 月, 火...'. So how do I set the component property?

This is the code I wrote.

<Calendar
    calendarType='US'
    locale='ja'
    value={startDate}
    onChange={changeMethod}         
/>

From the React Calendar documentation

formatDay Function called to override default formatting of day tile labels. Can be used to use your own formatting function.

(locale, date) => formatDate(date, 'd')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM