View Single Post
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-22-2017 , 15:32   Re: ConvertFloatToSeconds Stock (Useful for Songs)
Reply With Quote #6

Quote:
Originally Posted by edon1337 View Post
In YouTube, songs length are displayed in minute:seconds format. Furthermore, when you want to print the length of a video in chat, if you use 'Video Length: 195.0 seconds' they'll get confused lol. It's better for the readability. I personally needed this stock so I posted it here for other people. I don't get what you're trying to say with '3:15 as 3.15', how would you convert 3:15 to seconds? It's not even a number.



I'll try your method, thanks .
That's the thing - the minute:seconds format is a string. In your example you defined MUSIC_LENGTH to 3.15.
It's more logical to store a timespan as the number of seconds. 3.15 is not the number of seconds, 195.0 is. It's much easier to convert 195.0 to that string representation than 3.15. You'll find that in any programming language / library that can work with timespans. It's also really easy to convert "3:15" back to 195.

Last edited by klippy; 11-22-2017 at 15:33.
klippy is offline