*[TIME:${now}:{add}:${playtime}:{hh_mm_ss}]

You have a question or need an advice about how to do something? Ask it here!
Post Reply
atlantic
Posts: 120
Joined: 09 Apr 2012 18:35
Location: Belgium
Contact:
*[TIME:${now}:{add}:${playtime}:{hh_mm_ss}]

Post by atlantic »

Can this formula work:
Nowplay*[TIME:${now}:{add}:${playtime}:{hh_mm_ss}].jpg
This should result in something like:
Nowplay15_21_31.jpg
(${now} + ${playtime} = 15_21_31
User avatar
radio42
Site Admin
Posts: 9010
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: *[TIME:${now}:{add}:${playtime}:{hh_mm_ss}]

Post by radio42 »

The format of the macro function is:

Code: Select all

*[TIME:{value}:{add}:{num}:{format}]
The brackets are part of the syntax - you are not using them... i.e. don't remove them, even when using inner macros.
Example:
*[TIME:{15:26:03}:{seconds}:{185}:{hh'_'mm'_'ss}]

{value} : The original time format (as a double or in '[d.]hh:mm:ss[.ff]')
{add} : the conversion function name (ms, seconds, minutes, hours, ab', none)
{num}: the number of units to add as a numeric value according to the conversion function
{format}: the format of the resulting time string (hh, mm, ss; other characters must be enclose it in single quotation marks)

So what is all wrong in your code example:

a) don't remove the brackets
b) the macro ${now} is resolved as a date and time string and not to a time value as expected by the function
Use the ${HH}, ${mm} and ${ss} macros instead to create a time value accordingly (add the colons in between)
c) Use a conversion function (instead of add, e.g. use ms
d) the ${playtime} does not resolve in a numeric value, but a string. I.e. use the ${playtimems} value instead.
e) the format string is not correct, other characters must be enclosed in single quotes

So the correct command function should look like this:

Code: Select all

*[TIME:{${HH}:${mm}:${ss}}:{ms}:{${playtimems}}:{hh'_'mm'_'ss}]
Let's assume it is 2026.01.22 15:26:03 and the playtime of the track is 3 minutes and 5 seconds (or 185000 milliseconds).
First the internal macros are resolved, so the function will now look like this:
*[TIME:{15:26:03}:{ms}:{185000}:{hh'_'mm'_'ss}]

As such, 185000 ms are added to 15:26:03, which will result to 15:29:08. And this is now formatted to: 15_29_08
atlantic
Posts: 120
Joined: 09 Apr 2012 18:35
Location: Belgium
Contact:
Re: *[TIME:${now}:{add}:${playtime}:{hh_mm_ss}]

Post by atlantic »

Thanks for the tip!

Post Reply