Text sensor and substract on Display

How to reduce the number of characters in a word?

I have an imported calendar from home assistant
I would like to display the time of the event, but only the day and month.
Now the sensor in the start_time attribute shows the following:
start_time: '2022-08-02 00:00:00'
and I would only need to display
'08-02'

I tried the following:

it.printf(it.get_width() - 18, it.get_height(), id(fonttext2), TextAlign::BOTTOM_RIGHT, “%s”, id(calendar_time).state.substr(5, 10).c_str());

But after a flawless compilation esp does not start.
Do you have another idea how to make such a sensor?

EDIT:
Now I tried different numbers and on substr and this works. I do not understand?

it.printf(it.get_width() - 18, it.get_height(), id(fonttext2), TextAlign::BOTTOM_RIGHT, “%s”, id(calendar_time).state.substr(0, 5).c_str());

EDIT2:
If I change the first number in substr, esp does not start, the only one that works is 0.
I can change the second number at will

Seems to me that even with first parameter=0 substr() doesn’t work :frowning:
(unicode string)

How does calendar_time look in the ESPHOME logs when imported?