iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
46.98k stars 2.3k forks source link

_dayjs.default.months is not a function #2524

Open omirbeck opened 11 months ago

omirbeck commented 11 months ago

Describe the bug I use dayjs.months() it's work in a project, but when I try to test with jest, test failed with TypeError: _dayjs.default.months is not a function

Expected behavior Expected that test passed, because I couldn't see this error in Chrome log Can you give advice how to solve this problem or work around? Information

fszhangYi commented 11 months ago

i have a same question too.

MatiasFacio-ParkHere commented 10 months ago

same issue

0song commented 9 months ago

https://day.js.org/docs/en/get-set/month

dayjs().month()

MatiasFacio-ParkHere commented 9 months ago

https://day.js.org/docs/en/get-set/month

dayjs().month()

it is a different method.

dayjs.months()

milhlhat commented 4 months ago

I had same issue when try to get list months of year, so here is my way: Array.from({ length: 12 }, (_, i) => ({ label: dayjs().locale('vi').month(i).format('MMMM'), value: i + 1 }));