Display text (or activate script) on a certain range of days

My problem is simelar to Display text on a certain day?.
I want to show e.g. a Christmas message like “We wish you all…” from 23rd until 26th Dec, and a similar New Year’s message at the end of the year.
How do I do this in a way that it triggers automatically every year?
And I also would like to activate a script (Snowfall) for a period of time in winter automatically triggered every year.
A complication here (and for the New Year’s message) is that it starts e.g. on 15th Dec this year and ends on 28th Feb next year.
On the platform I formerly used, I had a PHP-based plugin. Could I use (or find) a similar solution in Grav? So far I have no clue how to set up such a thing. :frowning:


You could pretty easily convert the plugin for Grav, but Twig works as well. Just do a conditional on "now"|date(), something like:

{% set today = "now"|date('m-d') %}
Today is {{ today }}

{% if today > '11-22' or today <= '03-21' %}
{% elseif today > '03-21' and today <= '06-21' %}
{% elseif today > '06-21' and today <= '09-22' %}
{% elseif today > '09-22' and today <= '11-22' %}
{% endif %}

The same condition, adapted for your periods, works for adding the JS-script. If the period is variable between years, you’ll need to find the date-expression supported by PHP for this variance. If it’s very specific, you might need a helper-library, or to convert the plugin after all.