Jump to content
UBot Underground

Recommended Posts

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?

Link to post
Share on other sites

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"))


  • Like 1
Link to post
Share on other sites

 

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...