lolada 1 Posted May 29, 2016 Report Share Posted May 29, 2016 Hello guys someone can help me please? i have a label with the time like this "1h 30M 10S. i need to transform this in seconds. anyone has an idea how i can do it please? Quote Link to post Share on other sites
deliter 203 Posted May 30, 2016 Report Share Posted May 30, 2016 Hey My regular expressions suck and are really basic,but that might help you as they dont look too confusing define $convertTime(#timeString) { set(#count,0,"Local") if($comparison($find regular expression(#timeString,"(?i)\\d+h"),">",$nothing)) { then { set(#hourSec,$multiply($find regular expression($find regular expression(#timeString,"(?i)\\d+h"),"\\d+"),3600),"Local") set(#count,$add(#count,#hourSec),"Local") } } if($comparison($find regular expression(#timeString,"(?i)\\d+m"),">",$nothing)) { then { set(#minSec,$multiply($find regular expression($find regular expression(#timeString,"(?i)\\d+m"),"\\d+"),60),"Local") set(#count,$add(#count,#minSec),"Local") } } if($comparison($find regular expression(#timeString,"(?i)\\d+s"),">",$nothing)) { then { set(#minSec,$find regular expression($find regular expression(#timeString,"(?i)\\d+s"),"\\d+"),"Local") set(#count,$add(#count,#minSec),"Local") } } return(#count) } alert($convertTime("1h 30M 10S")) 1 Quote Link to post Share on other sites
pash 504 Posted May 30, 2016 Report Share Posted May 30, 2016 1m = 60s1h = 60m = 3600s ?s = h + m + s 1h 30M 10S = ?s3600 + 1800 + 10 = 5410s Quote Link to post Share on other sites
lolada 1 Posted May 30, 2016 Author Report Share Posted May 30, 2016 A pick time from label's website. Time is not always the same, if it was always the same, would be pretty easy Quote Link to post Share on other sites
deliter 203 Posted May 30, 2016 Report Share Posted May 30, 2016 you want to change it on the website itself? use the function i posted above with the change attribute command or post the site here Quote Link to post Share on other sites
lolada 1 Posted May 30, 2016 Author Report Share Posted May 30, 2016 Hey My regular expressions suck and are really basic,but that might help you as they dont look too confusing define $convertTime(#timeString) { set(#count,0,"Local") if($comparison($find regular expression(#timeString,"(?i)\\d+h"),">",$nothing)) { then { set(#hourSec,$multiply($find regular expression($find regular expression(#timeString,"(?i)\\d+h"),"\\d+"),3600),"Local") set(#count,$add(#count,#hourSec),"Local") } } if($comparison($find regular expression(#timeString,"(?i)\\d+m"),">",$nothing)) { then { set(#minSec,$multiply($find regular expression($find regular expression(#timeString,"(?i)\\d+m"),"\\d+"),60),"Local") set(#count,$add(#count,#minSec),"Local") } } if($comparison($find regular expression(#timeString,"(?i)\\d+s"),">",$nothing)) { then { set(#minSec,$find regular expression($find regular expression(#timeString,"(?i)\\d+s"),"\\d+"),"Local") set(#count,$add(#count,#minSec),"Local") } } return(#count) } alert($convertTime("1h 30M 10S")) Thank u very much, it worked for me Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.