dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

_dayjs.default.months is not a function

Open omirbeck opened this issue 1 year ago • 5 comments

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

  • Day.js Version [e.g. v1.10.7]
  • OS: [e.g. Windows 11]
  • Browser [e.g. chrome 119.0.6045.200]
  • Time zone: [e.g. GMT+06:00 DST (Pacific Daylight Time)]

omirbeck avatar Dec 07 '23 11:12 omirbeck

i have a same question too.

fszhangYi avatar Dec 11 '23 09:12 fszhangYi

same issue

MatiasFacio-ParkHere avatar Jan 08 '24 13:01 MatiasFacio-ParkHere

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

dayjs().month()

0song avatar Jan 22 '24 09:01 0song

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

dayjs().month()

it is a different method.

dayjs.months()

MatiasFacio-ParkHere avatar Jan 22 '24 09:01 MatiasFacio-ParkHere

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 }));

milhlhat avatar Jul 04 '24 04:07 milhlhat