SteveDinn
(Steve Dinn)
July 7, 2023, 5:42pm
1
If anyone has ever tried to do this, you know it can be a pain in the ass. Here’s a template that will return true when today is Easter Sunday
{# calculation algorithm from http://www.oremus.org/liturgy/etc/ktf/app/easter.html #}
{%- set now = now() -%}
{%- set year = now.year -%}
{%- set golden_number = (year % 19) + 1 -%}
{%- set solar_correction = ((year - 1600) / 100) | int - ((year - 1600) / 400) | int -%}
{%- set lunar_correction = ((((year - 1400) / 100) * 8) / 25) |int -%}
{%- set paschal_full_moon = (3 - (11 * golden_number) + solar_correction - lunar_correction) % 30 -%}
{%- if (paschal_full_moon == 29) or ((paschal_full_moon == 28) and (golden_number > 11)) -%}
{%- set paschal_full_moon = paschal_full_moon - 1 -%}
{%- endif -%}
{%- set dominical_number = (year + (year / 4) | int - (year / 100) | int + (year / 400) | int) % 7 -%}
{%- set first_sunday = (8 - dominical_number) % 7 -%}
{%- set days_between_easter_and_pfm = (4 - dominical_number - paschal_full_moon) % 7 + 1 -%}
{%- set easter_after_march21 = paschal_full_moon + days_between_easter_and_pfm -%}
{%- set easter = now.replace(month=3, day=21) + timedelta(days=easter_after_march21) -%}
{{ (now.month == easter.month) and (now.day == easter.day) }}
6 Likes
tom_l
July 7, 2023, 6:23pm
2
I wonder why they made it so complicated compared to his birthday.
Is this for Western or Orthodox Easter?
2 Likes
nickrout
(Nick Rout)
July 7, 2023, 8:22pm
4
SteveDinn
(Steve Dinn)
July 7, 2023, 8:46pm
5
Maybe? But how do you do it? I know I can tell that Easter would not be a workday with that integration. But how would I know it was actually “Easter”?
Anyway, I spent 30 minutes working on that, so don’t take this away from me
1 Like
nickrout
(Nick Rout)
July 7, 2023, 8:56pm
6
Not sure you can do it with the workday sensor, but I feel the underlying library should be able to do it.
Not to burst your bubble, but Petro built it into his easy time macros in April…
1 Like
petro
(Petro)
July 7, 2023, 11:46pm
8
And here
When you reply to people, make sure you reply to the person not the thread.
I have canned macros for dates that you can use.
Use these charts to fill in the required number for each macro.
month
number
January
1
February
2
March
3
April
4
May
5
June
6
July
7
August
8
September
9
October
10
November
11
December
12
week
number
1st
1
2nd
2
3rd
3
4th
4
5th
5
6th
6
day
number
Monday
0
Tuesday
1
Wednesday
2
Thursday
3
Friday
4
S…
for easy time macros , just install it and then it’s simply
{% from 'easy_time.jinja' import easter %}
{{ easter() }}
2 Likes