pinkywafer / Anniversaries

Anniversary Countdown Sensor for Home Assistant
MIT License
169 stars 26 forks source link

Friday 13th #159

Open lazyandproud opened 9 months ago

lazyandproud commented 9 months ago

Is it possible to create a recurring entry for the next Friday 13th?

TheFes commented 1 month ago

Here is a template which will give you the next Friday the 13th

{% set start = now().date().replace(day=13) %}
{% set start = (start + timedelta(days=30)).replace(day=13) if start < now().date() else start %}
{% set ns = namespace(friday_13th=start) %}
{% for i in range(50) %}
  {% if ns.friday_13th.weekday() == 4 %}
    {% break %}
  {% endif %}
  {% set ns.friday_13th = (ns.friday_13th + timedelta(days=30)).replace(day=13) %}
{% endfor %}
{{ ns.friday_13th }}

Apparently the next one is December