hey i really need some help. I am trying to mulitply a time format with a number example:
00:03:25 * 0,5 - > ??:??:??
i tried splitting the string and then mulitplient everything by itself, but then I have an array with these items: [00, 03, 35] and I would have to delete the leading zeros, and I dont know how to put the splitted array back together.
does someone know how to work with the time and multiply it?
multiply a time format with a percentage
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: multiply a time format with a percentage
Hi Fanny,
the trick is to convert to SECONDS first like this, tested and works:
Gives:
00:03:25
00:01:43
Best
Klaus
the trick is to convert to SECONDS first like this, tested and works:
Code: Select all
on mouseUp
put "00:03:25" into tDate
## We need to subtract the whole day from the seconds or we will get something like:
## 85632:01:43 instead of the desired 00:01:43
put the date into tDatum
convert tDatum to seconds
convert tDate to seconds
subtract tDatum from tDate
## Now do the math:
put round(tDate * .5) into tDate2
## Format as desired as SMPTE-lite:
put smpt_lite(tDate) & CR & smpt_lite(tDate2)
end mouseUp
function smpt_lite tSecs
return format("%02d:%02d:%02d", tSecs div 3600, (tSecs mod 3600) div 60, tSecs mod 60)
end smpt_lite
00:03:25
00:01:43
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: multiply a time format with a percentage
Hi.
I am curious. I can understand scaling a time period one way or the other, but wonder what use it could be to scale an actual moment in time. What would you do with cutting the "seconds", say, in half?
Craig
I am curious. I can understand scaling a time period one way or the other, but wonder what use it could be to scale an actual moment in time. What would you do with cutting the "seconds", say, in half?
Craig
Re: multiply a time format with a percentage
Klaus wrote: ↑Thu May 20, 2021 4:59 pmHi Fanny,
the trick is to convert to SECONDS first like this, tested and works:Gives:Code: Select all
on mouseUp put "00:03:25" into tDate ## We need to subtract the whole day from the seconds or we will get something like: ## 85632:01:43 instead of the desired 00:01:43 put the date into tDatum convert tDatum to seconds convert tDate to seconds subtract tDatum from tDate ## Now do the math: put round(tDate * .5) into tDate2 ## Format as desired as SMPTE-lite: put smpt_lite(tDate) & CR & smpt_lite(tDate2) end mouseUp function smpt_lite tSecs return format("%02d:%02d:%02d", tSecs div 3600, (tSecs mod 3600) div 60, tSecs mod 60) end smpt_lite
00:03:25
00:01:43
Best
Klaus
hello klaus,
sorry fo the late response, but thank you!!! that is amazing, yes it works. You really helped me!