Hello,
I have a user macro (developed by someone else who is no longer available to help debug) which worked in Confluence 6.13.7 but no longer works in 7.4. For context, I'm a Confluence administrator but do not understand Velocity in-depth.
I've determined where the issue is and probably what's happening, but I don't know how to fix it:
#set($review=$content.currentDate)
#set($valid=$content.lastModificationDate)
#set($diff=$review.getTime()-$valid.getTime())
The above code is the offender: the third line uses the .getTime() method on $review and $valid to return the unix time of each date and compare them to finally return a number of milliseconds difference between the two ($diff).
This works fine in 6.13 but in 7.4 it appears that the .getTime() method no longer works on the $valid variable. I suspect that it's because the data type is wrong or something like that. Is it possible to somehow convert the data so I can apply the method to it?
I wrote a very basic macro just to output the contents to the screen for troubleshooting:
## @noparams
#set($review=$content.currentDate)
#set($valid=$content.lastModificationDate)
#set($diff=$review.getTime()-$valid.getTime())
<h2>Vanilla</h2> <br>
$review <br>
$valid <br>
$diff <br>
<br>
<h2>GetTime Method Applied</h2> <br>
$review.getTime() <br>
$valid.getTime() <br>
$diff <br>
<br>
As an example, this is the output that I get:
Vanilla
Tue Jun 30 10:31:02 CEST 2020
2020-06-30 09:29:37.283
$diff
GetTime Method Applied
1593505862585
$valid.getTime()
$diff
What's really strange is that when I created this same troubleshooting macro in 6.13, the output in the vanilla section for $valid *looks* the same format in both versions of confluence - e.g. *2020-06-30 09:29:37.283* but the data is obviously not the same type.
Any help appreciated!