Well then it’s solved. That’s what I did till now but I was looking for a better solution.
Just to provide a little bit of background here, the reason why it won’t work is that the transformation always returns a String and the result of the transform gets passed to the label formatter (i.e. the %s). So when you have a transformation, the sorts of label manipulation that is available to you is limited to what you can do with a String. %1td et. al. only apply to DateTime objects.
When you don’t have a transformation in the label (e.g. [%1$td.%1$tm.%1$ty, %1$tH:%1$tM]) the DateTimeType is what gets passed to the formatter so it can take apart the Object and build the string in the format specified.
When you have a transformation in the label (e.g. [JS(sek_zu_hms.js):%s]) the DateTimeType get’s lost. First the DateTimeType gets passed to the transformation which does it’s transfomration and then returns a String and that String get’s passed to the label formatter. It’s now a String so %1$td is meaningless in that case.
I don’t know what you mean by “Item declaration accepts type DateTime”.
No, all transforms receive the state as a String in all cases. That’s how transformations work. But you don’t have to throw away the fact that an Item is a DateTime for everything else that uses that Item as a DateTime in OH because of the way that transformations work to show the label.
Exactly, because you are not using a transformation. Therefore the state doesn’t get converted to a String and the %1$td can work.
I already explained why that’s the case. Once you involve a transformation the DateTimeType gets converted to a String and all that you have to work with is a String from that point forward to build the label. %1$td et. al. only work with a DateTimeType. If you use a transformation, you lose the DateTimeType.
When you do not involve a transformation, no conversion occurs and the state remains a DateTimeType so %1$td works.