diff --git a/package.json b/package.json index 287d340..a6d09f0 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@juggle/resize-observer": "^3.4.0", "@popperjs/core": "^2.11.8", "lodash": "^4.17.21", - "luxon": "^3.0.1", + "luxon": "^3.4.4", "polished": "^4.3.1", "popper-max-size-modifier": "^0.2.0", "react-is": "^18.2.0", @@ -68,7 +68,7 @@ "@testing-library/user-event": "^14.2.0", "@types/jest": "^28.1.1", "@types/lodash": "^4.14.182", - "@types/luxon": "^2.3.2", + "@types/luxon": "^3.4.2", "@types/mdx": "^2.0.2", "@types/react-dom": "^18.0.5", "@types/react-is": "^17.0.3", diff --git a/src/helpers/calendarHelpers.ts b/src/helpers/calendarHelpers.ts index ca9340a..9d8c56d 100644 --- a/src/helpers/calendarHelpers.ts +++ b/src/helpers/calendarHelpers.ts @@ -54,19 +54,19 @@ export function getCalendarDays(month: DateTime, weekdays: ReadonlyArray const previousMonth = month.minus({months: 1}); const nextMonth = month.plus({months: 1}); + const daysInMonth = month.daysInMonth ?? 0; + const daysInPreviousMonth = previousMonth.daysInMonth ?? 0; + // Figure out the size of the left & right padding. const startOfmonth = month.startOf('month'); const previousPad = weekdays.indexOf(startOfmonth.weekday); - const rows = Math.ceil((month.daysInMonth + previousPad) / 7); + const rows = Math.ceil((daysInMonth + previousPad) / 7); const totalBoxes = rows * 7; - const nextPad = totalBoxes - (previousPad + month.daysInMonth); + const nextPad = totalBoxes - (previousPad + daysInMonth); // Build the day numbers for each range. - const previousMonthDayNumbers = range( - previousMonth.daysInMonth - previousPad + 1, - previousMonth.daysInMonth + 1 - ); - const currentMonthDayNumbers = range(1, month.daysInMonth + 1); + const previousMonthDayNumbers = range(daysInPreviousMonth - previousPad + 1, daysInPreviousMonth + 1); + const currentMonthDayNumbers = range(1, daysInMonth + 1); const nextMonthDayNumbers = range(1, nextPad + 1); // Map the day numbers to datetimes. diff --git a/yarn.lock b/yarn.lock index a03c384..4394dfb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3652,10 +3652,10 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2" integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q== -"@types/luxon@^2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-2.3.2.tgz#8a3f2cdd4858ce698b56cd8597d9243b8e9d3c65" - integrity sha512-WOehptuhKIXukSUUkRgGbj2c997Uv/iUgYgII8U7XLJqq9W2oF0kQ6frEznRQbdurioz+L/cdaIm4GutTQfgmA== +"@types/luxon@^3.4.2": + version "3.4.2" + resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-3.4.2.tgz#e4fc7214a420173cea47739c33cdf10874694db7" + integrity sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA== "@types/mdast@^3.0.0": version "3.0.10" @@ -9600,10 +9600,10 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -luxon@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.0.1.tgz#6901111d10ad06fd267ad4e4128a84bef8a77299" - integrity sha512-hF3kv0e5gwHQZKz4wtm4c+inDtyc7elkanAsBq+fundaCdUBNJB1dHEGUZIM6SfSBUlbVFduPwEtNjFK8wLtcw== +luxon@^3.4.4: + version "3.4.4" + resolved "https://registry.yarnpkg.com/luxon/-/luxon-3.4.4.tgz#cf20dc27dc532ba41a169c43fdcc0063601577af" + integrity sha512-zobTr7akeGHnv7eBOXcRgMeCP6+uyYsczwmeRCauvpvaAltgNyTbLH/+VaEAPUeWBT+1GuNmz4wC/6jtQzbbVA== lz-string@^1.4.4: version "1.4.4"