Simple Script Needed to Calculate How Many "15" Minutes are in a Time Stamp
Hello,
I am performing some work on some mp3 files. One the functions requires me to know how many "15 minutes" are in a particular file. For instance, I need some code that will produce the following values from the given time stamp: 01:52:34.40 = 7 00:47:15.32 = 3 00:02:56.41 = 0 00:36:01.09 = 2 Any ideas? |
If I echo : $("$t" | awk -F: '{ print ($1 * 60) + ($2)}' - I get the correct number of minutes
But if I try m=$("$t" | awk -F: '{ print ($1 * 60) + ($2)}') where $t is the timestamp, I get an error message: ./processmix: line 27: 00:32:34.40: command not found |
??? just convert everything to a minute (add 1 for any seconds), mod 15. add 1 for any nonzero remainder.
|
Quote:
|
Quote:
I also think you need the seconds to be included - otherwise you might get some truncated video (up to a minutes worth). Oh, and include 1 any remainder from the modulus as otherwise you would loose up to 14 minutes worth. |
Thanks, that works a treat now :)
|
Whenever you are working with times and involve calculation, use seconds.
Code:
echo $(date -d "1970-01-01 1:52:34" +%s) 900 / p | dc |
Quote:
|
Quote:
Which is the way it should be set up IMHO. Time is time, and converting it to the local time zone should be performed in the display layer, not on the machine level. I run servers in different time zones and timestamps are a nightmare when different times are displayed. Anyways, -u is a mandatory option if your system time isn't UTC. jlinkels |
All times are GMT -5. The time now is 12:15 PM. |