How to calculate dates with with a custom property of type Duration

Since LO version 7.5 it finally works to create a custom property (File/Properties/Custom Properties) of type Duration – in previous versions the type was reset to Text when leaving the Properties dialog.

So my naive assumption was that I could go ahead now and calculate a date from a start date and a duration. Only so far I was unable to find anything that worked. The documentation for LO writer does not even have anything on custom properties of type duration, let alone an example for its usage or calculations with it. The Wiki, too, does not have anything on it. And any attempts to reference the custom properties in a formula failed as well.

Does anybody have an idea how to do it or a pointer where to look – other than the source code?

Hendrik

Already present in 7.4 releases but I have no idea about the Duration use.

You (@BasicBaer) surely want to do your calculations in Basic?
Well, there are the API structures you can use like in

Dim nowDateTime  As New com.sun.star.util.DateTime
Dim someDuration As New com.sun.star.util.Duration  

but I don’t know any Basic functions prepared to work with these structures, nor seems to be there an API service for related purposes.

In Writer the DateTime structure is used for some TextField objects.

You may need to write your “service functions” yourself.
If a startDateTime and a duration are given as values of the mentioned structures, this is easy for your example. If it’s useful is doubtable, however. What sense in using durations resolved to nanoseconds together with calendaric DateTime values depending on every kind of nonsense? Even UTC differences aren’t durations usable in science or engineering.

Store your durations as numbers -or better as strings- based on the unit s (with a fractional part if needed) as any engineer would do.

Hi Lupp.

If I can avoid using Macros, regardless if Basic, Python or JavaScript, and get away with a simple Formula, I would be quite happy.

Concerning the usefulness: Consider creating a document that is the invitation to an event and giving information like The Convention starts at StartDate, ends at Date (StartDate + EventDuration). You need to have submitted your registration by (StartDate - RegistrationAdvance), and you need to have payed by (StartDate - PayAdvance), …
If the event happes twice a year you only need to change one date in the properties and you are done.
Also ISO8601 explicitly defines not only DateTime but also Duration.

@ajlittoz: it was even in 7.3, but broken until 7.5

Yes (though only the communication formats). This, however, can’t assure that the information is meaningful and unambiguous.
If something started on 2022-10-30: Assume It’s T02:30 and you want to add PT1H10M . You see? And doing it for 2025-10-26? Will the underlying nonsense be abandoned then eventually? Or ist it 2 weeks earlier? Or are you in a different country?
If you give the start in ISO 8601, and if the duration is “full calendaric days” and also given in ISO 8601, and neither is touched a “DST switch” nor did the event move into a different time zone … , it’s simple and reasonable. The related API structures won’t help. If it’s not simple, you need to be an expert, and the mentioned structures again won’t help.