Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 2x 2x 11x 11x 11x 3x 8x | import { startOfWeek, differenceInDays, addWeeks } from "date-fns";
/**
*
* @param {number} churchYear - The full year of the Church year as it will be at Easter
* Sunday (e.g. 2024 means that Advent begins in 2023)
*/
export const getAdventStartDate = (churchYear: number) => {
const stAndrewsDay = new Date(churchYear - 1, 10, 30);
const nearestSunday = startOfWeek(stAndrewsDay);
if (differenceInDays(stAndrewsDay, nearestSunday) < 4) {
return nearestSunday;
}
return addWeeks(nearestSunday, 1);
};
|