When is this event? n days ago, yesterday, today, tomorrow, in n days?

This should be easy, but I’m failing to express when an event is in terms of which days it occurs relative to today. Was it yesterday, to day etc. I’ve tried comparing event_as_datetime.day with now().day but it fails over the change of month. I’ve tried (event_as_datetime - now()).days but weirdly this regards something that happened a a few minutes more than 24hrs ago as -2 days plus so many hrs:mins ago.
I can see in the Python docs that there is something called a date object, but I’ failing to find how to turn my event into one.
I’ve got this very inelegant expression to produce the correct number of days, but surely there is a better way?
{{ (as_datetime((when|string)[0:10])-as_datetime((now()|string)[0:10])).days}}

Copy-paste the following template into the Template Editor and experiment with it.

{% set dt1 = '2025-02-21 07:00:00' | as_datetime | as_local -%}
{% set dt2 = '2025-02-27 08:00:00' | as_datetime | as_local -%}

Example 1
{{ (now().date() - dt1.date()).days }}
{{ (dt2.date() - now().date()).days }}

Example 2
{{ time_since(dt1) }}
{{ time_until(dt2) }}
------------------------------------------------
{% set dt3 = '2025-03-22 09:00:00' | as_datetime | as_local -%}

Example 3
{% set (d1, d2) = iif(now() > dt3, (now(), dt3), (dt3, now())) -%}
{{ (d1.date() - d2.date()).days }}

Example 4
{{ time_since(dt3) if now() > dt3 else time_until(dt3) }}

Thanks. I hadn’t spotted ```time_since`` in the docs, that’s very useful. Why does it return the number of days though? The documentation says it will return the human readable interval, so I would have expected it to include hours and minutes.

It accepts a second argument called precision.

Reference

Templating - Time