Hi Magnus,

This is quick'n dirty but should give you a starting point at least:

<cfset long = "0:01:30 (approx)">
<cfset short = "8.41 s (approx)">

<cffunction name="getCleanTime" access="public">
<cfargument name="time" required="true">
<cfargument name="round" default="false">

<cfset ret = "">

<cfset tempTime = listFirst(arguments.time, " ")>
<cfif tempTime contains ".">
<cfset prefix = "0:00:">
<cfif arguments.round>
<cfset tempTime = round(tempTime)>
</cfif>

<cfif listFirst(tempTime, ".") LT 10>
<cfset tempTime = "0" & tempTime>
</cfif>
<cfset ret = prefix & tempTime>
<cfelse>
<cfset ret = tempTime>

</cfif>
<cfreturn ret>
</cffunction>

<cfoutput>
#getCleanTime(long, true)#<br>
#getCleanTime(short, true)#<br>
#getCleanTime(short)#<br>
</cfoutput>

On Sunday, December 20, 2015 at 9:24:28 PM UTC-5, Magnus wrote:
>
> I am extratingthe metadata from audio files nad I am having a challenge 
> with the duration date. In most cases this is easy to deal with: in comes 
> in the format "0:01:30 (approx)". I use  spanExcludsing to find the space 
> and exclude the rest leaving a easy to deal with time vaue. But when the 
> audio file ius very short the time value (aleast in some cases) is "8.41 s 
> (approx)". I am wondering if anyone has a suggestion on the best way to 
> capture this and convert ti to a value like above? 
>
> I suspect some regex is required but I am pretty green with that so any 
> help is appreciated.
>
> Magnus
>

-- 
-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Open 
BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to