Timer due date is calculated incorrectly if due date is in the next months

Hello,
I tried to find a solution in existed topics but couldn’t so I hope you can help me with my issue.
I have several timers in my flow but if some timer due date goes to the next months, the system calculates due date from the first date of month, not from timer creation date.
For example:
Timer creation date: 28.10.2022
Timer definition type - duration and definition R/PT168H (7 days)
Expected Timer due date: 02.11.2022
Actual Timer due date: 08.11.2022 (01.11.2022 + 7 days)

I’m not sure it’s correct behaviour. Is it a bug or I should change in my flow something?

Thank you in advance!

Why does your timer definition start with “R/”? Do you want to repeat it? Or should it be just one-off timer?

It should be one time. But I don’t think it influences this issue. It happened only for timers from October to November. I have flows where a timer goes from November to December and everything calculates correctly

Hi @venya.bohdan,

this sounds like a problem with switching from daylight saving time to winter time. Could you double-check if this is the case?

Hope this helps, Ingo

Hello @Ingo_Richtsmeier. Sounds like an issue, but I’m not sure how to check if it’s the problem. Could you suggest how to avoid this problem in the future?

Hi @venya.bohdan,

I was just speculating about the root cause.

Until nobody knows the reason, it’s hard to avoid it.

You can test the situation easily and repeatable with the help of this repository: https://github.com/camunda/camunda-engine-unittest

The result could be different if you set the Week with an explicit ISO Expression: P7D or P1W. See ISO 8601 - Wikipedia for further details.

Hope this helps, Ingo

Hello @Ingo_Richtsmeier,
Is it possible to start process in tests in the past? I tried to catch this bug by creation timers that goes to May (after changing winter time to summer) but everything works properly.
And I can’t reproduce this particular bug due to Camunda doesn’t provide possibility to set start process date, so I can’t set start date as October. Can I do this through API for example?
Thank you in advance.

Hi @venya.bohdan,

yes it is. The engine contains org.camunda.bpm.engine.impl.util.ClockUtil and org.camunda.bpm.engine.impl.calendar.DateTimeUtil to set the system time to a designated, fixed value.

For example

ClockUtil.setCurrentTime(DateTimeUtil.parseDate("2022-10-30T01:59:50"));

Hope this helps, Ingo