1 of 1 people found this helpful
This is pretty close to the approach I took a little while ago to doing this same thing. My solution used slightly less attributes than yours, but there are some similar steps:
I'm still using the Floor function to extract the values for the individual time components, but used a slightly different set of formatting rules when I concatenated the whole lot into a time string:
Is this a more 'elegant' solution? Not really, but it does use a slightly less complicated child attribute hierarchy to accomplish the end result.
Hopefully others in the community might have found a more elegant way to do this.
Hope this helps.
3 of 3 people found this helpful
You could use an Analysis and a little bit of trickery. An AFAttribute does not support a TimeSpan value type directly, but it does support <Anything> which can be any object type. The problem is the burden is on you to correctly assign the object value. On the surface this sounds a bit complicated but it's actually a few simple steps.
First, here's my structure. The Seconds attribute is static for this simple example but it could just as easily be assigned to a PIPoint. You do not have to map the output to a PIPoint.
TimeSpan is configured as:
The Analysis is defined as:
This example would produce decimal seconds if the input has them. So you could end up with:
If you absolutely, positively only want integer seconds, you would add an extra expression:
You might be tempted to perform the first UOM conversion and truncation to integer in one expression. However, if your input is every not seconds, perhaps its hours, you really want to take the double hours and convert to double seconds, and only after that is done should you truncate to integer seconds.