Not sure it’ll be much help as it’s calculated from a rest sensor from my councils website, it returns a date. This is the template sensor
{% set x = states('sensor.date_time') %}
{% set next = state_attr('sensor.eyrc_bin_days', 'GreenDate') %}
{% if next != 'unknown' and next != '' %}
{% set diff = as_timestamp(next, 0) - as_timestamp(now(), 0) %}
{% if ((diff / 86400)+1) < 0 %}
{% set days = 15 %}
{% else %}
{% set days = ((diff / 86400)+1) | int(0) %}
{% endif %}
{{ days }}
{% else %}
Failed to Update
{% endif %}