10-22-2015 01:59 PM
I have a numeric input box for my UIR panel, called TestLength in seconds. I want to add both a hour input and minutes input. Right now, i am thinking of just adding three seperate numeric input boxes, hour, minutes, and seconds. And then in code, put them together in a variable total_seconds. So like, total_seconds = (hour_input*60*60) + (min_input*60)+ sec_input;
I was wondering if there is an easier way to do this, or if this is the best approach.
10-23-2015 12:51 AM
I see three possibilities:
10-23-2015 03:07 AM - edited 10-23-2015 03:11 AM
I normally let the user input the desired time value in a string control and post-process the text entered extracting the corresponding value. I developed a function for that which I have now published for all who can be interested: you can find it here.
The function accepts strings like "2h 15m", "2:15:00", "2.15.0", "8100s" and "8100" returning 8100 seconds in all cases.