From 28654f1132c1c6aa2bc1fe851d8c40993cbff8b4 Mon Sep 17 00:00:00 2001 From: LuLaValva Date: Wed, 1 Nov 2023 16:57:24 +0100 Subject: [PATCH 1/3] fix(calendar): strange timezone bug --- src/components/ebay-calendar/component.js | 15 ++++++++------- src/components/ebay-calendar/index.marko | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/ebay-calendar/component.js b/src/components/ebay-calendar/component.js index 8d2071d29..dab5267d2 100644 --- a/src/components/ebay-calendar/component.js +++ b/src/components/ebay-calendar/component.js @@ -240,8 +240,7 @@ export default class extends Marko.Component { getMonthDate(offset) { const baseDate = fromISO(this.state.baseISO); const date = new Date( - baseDate.getUTCFullYear(), - baseDate.getUTCMonth() + offset + Date.UTC(baseDate.getUTCFullYear(), baseDate.getUTCMonth() + offset) ); return date; } @@ -254,11 +253,13 @@ export default class extends Marko.Component { const baseDate = fromISO(this.state.baseISO); return toISO( new Date( - baseDate.getUTCFullYear(), - baseDate.getUTCMonth() + - this.state.offset + - (input.numMonths || 1), - 0 + Date.UTC( + baseDate.getUTCFullYear(), + baseDate.getUTCMonth() + + this.state.offset + + (input.numMonths || 1), + 0 + ) ) ); } diff --git a/src/components/ebay-calendar/index.marko b/src/components/ebay-calendar/index.marko index dcc7ea91b..362bb128b 100644 --- a/src/components/ebay-calendar/index.marko +++ b/src/components/ebay-calendar/index.marko @@ -68,7 +68,7 @@ $ var a11ySeparator = input.a11ySeparator ?? " - "; $ endDate = daysInMonth; - $ var dayISO = toISO(new Date(year, month, day)); + $ var dayISO = toISO(new Date(Date.UTC(year, month, day))); $ var isToday = dayISO === state.todayISO; $ var isSelected = (Array.isArray(input.selected) ? input.selected.some((iso) => iso === dayISO) From 0b6ef9b732fdf3d99a6cd2e07fb55d6c022c2eb1 Mon Sep 17 00:00:00 2001 From: LuLaValva Date: Mon, 6 Nov 2023 09:24:05 -0800 Subject: [PATCH 2/3] fix(calendar): adjust monthTitle for timezone --- src/components/ebay-calendar/component.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ebay-calendar/component.js b/src/components/ebay-calendar/component.js index dab5267d2..cfdfd5d17 100644 --- a/src/components/ebay-calendar/component.js +++ b/src/components/ebay-calendar/component.js @@ -293,7 +293,9 @@ export default class extends Marko.Component { year: "numeric", } ); - return formatter.format(date); + return formatter.format( + new Date(date.getUTCFullYear(), date.getUTCMonth()) + ); } /** From 355442058ba5bfaf976b80b4bf5aadb8d3884163 Mon Sep 17 00:00:00 2001 From: LuLaValva Date: Mon, 6 Nov 2023 10:15:20 -0800 Subject: [PATCH 3/3] feat(ts): optimize hiding fully disabled months --- src/components/ebay-calendar/component.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/ebay-calendar/component.js b/src/components/ebay-calendar/component.js index cfdfd5d17..f01ac7792 100644 --- a/src/components/ebay-calendar/component.js +++ b/src/components/ebay-calendar/component.js @@ -143,6 +143,14 @@ export default class extends Marko.Component { // In this case, we leave the tabindex and position as is. This is a fall-through case. } } + while ( + this.state.disableAfter && + this.getMonthDate( + this.state.offset + (input.numMonths || 1) - 1 + ).toISOString() > this.state.disableAfter + ) { + this.state.offset--; + } } /**