Thanks, Marcus.
In the end, this is what I ended up doing:
<cfif reFind("[0-9]{1,2}\.[0-9]{1,2}",newFilesArray[i].duration)> <!--- if
the format is X.XX? The reformat to X:XX:XX.XX --->
<cfset lengthWholeNumber =
len(spanExcluding(newFilesArray[i].duration, "."))>
<cfif lengthWholeNumber IS 2>
<cfset newFilesArray[i].duration =
"0:00:#newFilesArray[i].duration#">
<cfelseif lengthWholeNumber IS 1>
<cfset newFilesArray[i].duration =
"0:00:0#newFilesArray[i].duration#">
</cfif>
</cfif>
FYI. the decimal values get dropped by the database when inserted as a time
value.
Magnus
On Wednesday, 23 December 2015 14:15:50 UTC-8, Marcus F wrote:
>
> 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.