RE: Time conversion...

new topic     » topic index » view thread      » older message » newer message

Hello again "LEVIATHAN",

heres some code to convert seconds to hours:minutes:seconds
and a demo...

include get.e

atom ink

function secs_To_hours_mins_secs_string(atom sec)

  integer hour,min,minA,secA


  secA=floor(sec+.5) --round seconds
  sec=remainder(secA,60)
  minA=(secA-sec)/60
  min=remainder(minA,60)
  hour=(minA-min)/60

  return  sprintf("%04d",hour)&  --modify "%04d" for your own use
          ":"&sprintf("%02d",min)&
          ":"&sprintf("%02d",sec)

end function

--demo:

atom sec
sequence minsec


sec=19234.5 --for example

minsec=secs_To_hours_mins_secs_string(sec)


printf(1,"%s\n",{minsec})

ink=wait_key()

Good luck with it.
--Al

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu