{"ScriptPreparationCode":"class DayModel {\r\n constructor(year, month, date) {\r\n this.year = year\r\n this.month = month\r\n this.date = date\r\n }\r\n\r\n /**\r\n * Checks if the passed CalendarDate is equal to itself.\r\n */\r\n isEqual(day) {\r\n if (day) {\r\n return (\r\n this.year === day.year \u0026\u0026\r\n this.month === day.month \u0026\u0026\r\n this.date === day.date\r\n )\r\n }\r\n return false\r\n }\r\n\r\n toDate() {\r\n return new Date(this.year, this.month, this.date)\r\n }\r\n\r\n /**\r\n * Returns a new DayModel which is incremented based on the value passed.\r\n */\r\n incrementBy(value) {\r\n // Creating new Javascript Date object to increment because\r\n // it will automatically take care of switching to next or previous\r\n // months \u0026 years without we having to worry about it.\r\n const date = new Date(this.year, this.month, this.date \u002B value)\r\n return new DayModel(date.getFullYear(), date.getMonth(), date.getDate())\r\n }\r\n\r\n /**\r\n * Clones the current day model.\r\n */\r\n clone() {\r\n return new DayModel(this.year, this.month, this.date)\r\n }\r\n\r\n toComparisonString() {\r\n return \u0060${this.year}${this.pad(this.month)}${this.pad(this.date)}\u0060\r\n }\r\n\r\n toDateString() {\r\n return this.toDate().toLocaleDateString(undefined, {\r\n weekday: \u0022long\u0022,\r\n month: \u0022long\u0022,\r\n day: \u0022numeric\u0022,\r\n year: \u0022numeric\u0022\r\n })\r\n }\r\n\r\n /**\r\n * Compares the dates and returns boolean value based on the value passed\r\n */\r\n isBefore(day, dayInclusive = false) {\r\n return dayInclusive ?\r\n this.toDate().getTime() \u003C= day?.toDate().getTime() :\r\n this.toDate().getTime() \u003C day?.toDate().getTime()\r\n }\r\n\r\n /**\r\n * Compares the dates and returns boolean value based on the value passed\r\n */\r\n isAfter(day, dayInclusive = false) {\r\n return dayInclusive ?\r\n this.toDate().getTime() \u003E= day?.toDate().getTime() :\r\n this.toDate().getTime() \u003E day?.toDate().getTime()\r\n }\r\n\r\n pad(num) {\r\n return num \u003C 10 ? \u00600${num}\u0060 : \u0060${num}\u0060;\r\n }\r\n}\r\n\r\nfunction getDaysInMonthJS(month, year) {\r\n const date = new Date(year, month, 1);\r\n const days = [];\r\n while (date.getMonth() === month) {\r\n days.push(new Date(date));\r\n date.setDate(date.getDate() \u002B 1);\r\n }\r\n return days;\r\n}\r\n\r\nfunction getDaysInMonthTS(month, year) {\r\n\tconst nbD = new Date(year, month \u002B 1, 0).getDate();\r\n return Array(nbD)\r\n .fill(null)\r\n .map((_date, index) =\u003E {\r\n return new DayModel(year, month, index \u002B 1);\r\n });\r\n}","TestCases":[{"Name":"Plain JS","Code":"getDaysInMonthJS(2024, 1)","IsDeferred":false},{"Name":"Day Class","Code":"getDaysInMonthJS(2024, 1)","IsDeferred":false}]}