@@ -48,9 +48,6 @@ jobs:
|
|||||||
unzip -q tools.zip
|
unzip -q tools.zip
|
||||||
rm tools.zip
|
rm tools.zip
|
||||||
|
|
||||||
mkdir -p cmdline-tools/latest
|
|
||||||
mv cmdline-tools/* cmdline-tools/latest/ 2>/dev/null || true
|
|
||||||
|
|
||||||
# 🔥 CRITICAL: disable all interactivity
|
# 🔥 CRITICAL: disable all interactivity
|
||||||
export GRADLE_OPTS="-Dorg.gradle.daemon=false"
|
export GRADLE_OPTS="-Dorg.gradle.daemon=false"
|
||||||
export TERM=dumb
|
export TERM=dumb
|
||||||
|
|||||||
@@ -52,34 +52,44 @@ export function BirthdayList() {
|
|||||||
|
|
||||||
// Helper function to group and sort
|
// Helper function to group and sort
|
||||||
function groupBirthdaysByDate(data: BirthdayEntry[]): SectionData[] {
|
function groupBirthdaysByDate(data: BirthdayEntry[]): SectionData[] {
|
||||||
// Sort by date
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const currentYear = today.getFullYear();
|
const currentYear = today.getFullYear();
|
||||||
|
const todayAtMidnight = new Date(today);
|
||||||
|
todayAtMidnight.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const daysUntilNext = (month: number, day: number) => {
|
const daysUntilNext = (month: number, day: number) => {
|
||||||
let target = new Date(currentYear, month, day);
|
let target = new Date(currentYear, month, day);
|
||||||
if(target < today.setHours(0, 0, 0, 0)){
|
if (target < todayAtMidnight) {
|
||||||
target = new Date(currentYear + 1, month, day);
|
target = new Date(currentYear + 1, month, day);
|
||||||
}
|
}
|
||||||
const msPerDay = 1000 * 60 * 60 * 24;
|
const msPerDay = 1000 * 60 * 60 * 24;
|
||||||
const diff = target - new Date(today.setHours(0,0,0,0));
|
const diff = target.getTime() - todayAtMidnight.getTime();
|
||||||
return Math.ceil(diff / msPerDay);
|
return Math.ceil(diff / msPerDay);
|
||||||
};
|
};
|
||||||
|
|
||||||
const sorted = [...data].sort((a, b) => {
|
const sorted = [...data].sort((a, b) => {
|
||||||
const dateA = parseBirthdayDate(a);
|
const dateA = parseBirthdayDate(a.date);
|
||||||
const dateB = parseBirthdayDate(b);
|
const dateB = parseBirthdayDate(b.date);
|
||||||
return daysUntilNext(dateA.getMonth(), dateA.getDate()) - daysUntilNext(dateB.getMonth(), dateB.getDate());
|
|
||||||
|
const nextBirthdayDiff =
|
||||||
|
daysUntilNext(dateA.getMonth(), dateA.getDate()) -
|
||||||
|
daysUntilNext(dateB.getMonth(), dateB.getDate());
|
||||||
|
|
||||||
|
if (nextBirthdayDiff !== 0) {
|
||||||
|
return nextBirthdayDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dateA.getFullYear() - dateB.getFullYear();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Group by date
|
|
||||||
const grouped = sorted.reduce((acc, item) => {
|
const grouped = sorted.reduce((acc, item) => {
|
||||||
const existing = acc.find((section) => section.title === item.date);
|
const sectionKey = getMonthDayKey(item.date);
|
||||||
|
const existing = acc.find((section) => section.title === sectionKey);
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
existing.data.push(item);
|
existing.data.push(item);
|
||||||
} else {
|
} else {
|
||||||
acc.push({ title: item.date, data: [item] });
|
acc.push({ title: sectionKey, data: [item] });
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
@@ -92,11 +102,20 @@ function parseBirthdayDate(date: string) {
|
|||||||
return new Date(`${date}T00:00:00`);
|
return new Date(`${date}T00:00:00`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMonthDayKey(date: string) {
|
||||||
|
const parsedDate = parseBirthdayDate(date);
|
||||||
|
const month = `${parsedDate.getMonth() + 1}`.padStart(2, "0");
|
||||||
|
const day = `${parsedDate.getDate()}`.padStart(2, "0");
|
||||||
|
|
||||||
|
return `${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
function formatDisplayDate(date: string) {
|
function formatDisplayDate(date: string) {
|
||||||
return parseBirthdayDate(date).toLocaleDateString(undefined, {
|
const [month, day] = date.split("-").map(Number);
|
||||||
|
|
||||||
|
return new Date(2000, month - 1, day).toLocaleDateString(undefined, {
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
year: "numeric",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user