aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/schedule-dates.ts18
-rw-r--r--src/lib/schedule-months.ts16
2 files changed, 33 insertions, 1 deletions
diff --git a/src/lib/schedule-dates.ts b/src/lib/schedule-dates.ts
index 719a9c6..eaa4a3a 100644
--- a/src/lib/schedule-dates.ts
+++ b/src/lib/schedule-dates.ts
@@ -148,3 +148,21 @@ export function entryDates(
}
return [...dates].sort();
}
+
+const monthKeyOf = (date: Date) => `${date.getFullYear()}-${pad2(date.getMonth() + 1)}`;
+
+/**
+ * メインページに載せる範囲の開始月(前月)。例: 2026-11-05 → 2026-10
+ * 前月分も残すことで、終わったばかりの予定をメインページで確認できる。
+ */
+export function mainStartMonth(now = new Date()): string {
+ return monthKeyOf(new Date(now.getFullYear(), now.getMonth() - 1, 1));
+}
+
+/**
+ * アーカイブ(月別・年度別ページ)に移す範囲の終わり月(前々月)。
+ * 例: 2026-11-05 → 2026-09。前月以前はメインページに残す。
+ */
+export function archiveEndMonth(now = new Date()): string {
+ return monthKeyOf(new Date(now.getFullYear(), now.getMonth() - 2, 1));
+}
diff --git a/src/lib/schedule-months.ts b/src/lib/schedule-months.ts
index 829fef5..bff86a2 100644
--- a/src/lib/schedule-months.ts
+++ b/src/lib/schedule-months.ts
@@ -4,7 +4,7 @@
// (カレンダー側が必要とする日付計算は src/lib/schedule-dates.ts にある)
import meetings from '@/data/schedule/meetings.json';
import events from '@/data/schedule/events.json';
-import { entryDates } from './schedule-dates';
+import { archiveEndMonth, entryDates } from './schedule-dates';
export type Row = { date: string; title: string; place: string; note: string; source: string };
export type Item = { type: 'meeting' | 'event'; row: Row };
@@ -76,3 +76,17 @@ export function rowsInMonths(months: string[], type: 'meeting' | 'event'): Row[]
export function rowsInFiscalYear(fy: string, type: 'meeting' | 'event'): Row[] {
return rowsInMonths(monthsInFiscalYear(fy), type);
}
+
+/**
+ * アーカイブ(月別・年度別ページ)に移す月。前々月以前。
+ * 前月と当月以降はメインページに残すので、ここには含めない。
+ */
+export const archiveMonthKeys: string[] = monthKeys.filter(
+ (month) => month <= archiveEndMonth(),
+);
+
+/** アーカイブに移す年度(その年度の最後の月が前々月以前のもの) */
+export const archiveFiscalYearKeys: string[] = fiscalYearKeys.filter((fy) => {
+ const months = monthsInFiscalYear(fy);
+ return months.length > 0 && months[months.length - 1] <= archiveEndMonth();
+});