aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lib/schedule-months.ts
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 13:40:32 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 13:40:32 +0900
commitff9bafe77a5e0dd84b613bb2aae0bf2a9cb84359 (patch)
treee86e638f80f94f42e67253eb27f0a8d36f4fe2d8 /src/lib/schedule-months.ts
parent881485f010d6d576bab958548e3c955b8067dd34 (diff)
events: 年度別アーカイブとRSSフィードを追加
月別ページに加えて、4月〜翌3月の年度ページ(/kodaira/events/r8/)を 追加した。月別リンクは年度ごとにまとめ、今後の予定はfeed.xmlで 配信する。
Diffstat (limited to 'src/lib/schedule-months.ts')
-rw-r--r--src/lib/schedule-months.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/schedule-months.ts b/src/lib/schedule-months.ts
index cd109b7..829fef5 100644
--- a/src/lib/schedule-months.ts
+++ b/src/lib/schedule-months.ts
@@ -42,3 +42,37 @@ export function monthLabel(key: string): string {
const [y, m] = key.split('-').map(Number);
return `${y}年${m}月`;
}
+
+/** 月キー → 年度キー(令和8年度は r8。4月〜翌年3月) */
+export function fiscalYearOf(month: string): string {
+ const [y, m] = month.split('-').map(Number);
+ const startYear = m >= 4 ? y : y - 1;
+ return `r${startYear - 2018}`;
+}
+
+/** データに存在する年度(昇順) */
+export const fiscalYearKeys: string[] = [...new Set(monthKeys.map(fiscalYearOf))].sort();
+
+/** 年度に含まれる月キー(データにある月だけ) */
+export function monthsInFiscalYear(fy: string): string[] {
+ return monthKeys.filter((month) => fiscalYearOf(month) === fy);
+}
+
+/** 年度の表示(r8 → 令和8年度) */
+export function fiscalYearLabel(fy: string): string {
+ return `令和${Number(fy.slice(1))}年度`;
+}
+
+/** 複数の月のいずれかに開催される行を返す */
+export function rowsInMonths(months: string[], type: 'meeting' | 'event'): Row[] {
+ const inMonths = (item: Item) =>
+ datesOf(item).some((date) => months.includes(date.slice(0, 7)));
+ return items
+ .filter((item) => item.type === type && inMonths(item))
+ .map((item) => item.row);
+}
+
+/** 年度に開催される行を返す */
+export function rowsInFiscalYear(fy: string, type: 'meeting' | 'event'): Row[] {
+ return rowsInMonths(monthsInFiscalYear(fy), type);
+}