1. Time conversion...

Heya all!

I wonder, is there a better way to do this function? I mean, it
seems
to have so much unnecessary stuff, but it gets the job done...

Any advice?

TIA,

--"LEVIATHAN"

function secs_to_mins(integer secs)

atom conv
atom conv2
sequence final
object crap
object crap2
object crap3

conv = secs / 60
--conv3 = conv
crap = sprintf("%3.5f", conv)
crap2 = match(".", crap)
crap3 = crap[crap2..length(crap)]
crap3 = value(crap3)
crap3 = crap3[2]
conv = conv - crap3
crap = crap[crap2+1..length(crap)]
crap = value(crap)
crap = crap[2]
conv2 = crap * 60
conv2 = conv2
final = sprintf("%d", conv) & ":" &
sprintf("%2d", conv2)
crap = length(final)
crap = crap - 5
final = final[1..crap]

return final
end function

new topic     » topic index » view message » categorize

2. Re: Time conversion...

Hello,

The code looks very convoluted.  Couldn't you just use something like this or 
am I missing something?

function secs_to_mins(integer secs)
integer minutes
    minutes=floor(secs/60)
    return sprintf("%d:%02d",{minutes,floor(secs-minutes*60)})
end function


Would that suffice?

Vince

new topic     » goto parent     » topic index » view message » categorize

3. Re: Time conversion...

Hi, Vince.

I don't think you're missing a thing. Nice, tight function.

regards,

Jim 

Vincegg at AOL.COM wrote:
> 
> Hello,
> 
> The code looks very convoluted.  Couldn't you just use something like this or
> am I missing something?
> 
> function secs_to_mins(integer secs)
> integer minutes
>     minutes=floor(secs/60)
>     return sprintf("%d:%02d",{minutes,floor(secs-minutes*60)})
> end function
> 
> Would that suffice?
> 
> Vince
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: Time conversion...

Al was right, not tight enough:

function secs_to_mins(integer sex)
        return sprintf("%d:%02d", {floor(sex/60),remainder(sex,60)})
end function

jiri

----- Original Message -----
From: "Jim Duffy" <futures8 at earthlink.net>
To: "EUforum" <EUforum at topica.com>
Sent: Sunday, February 25, 2001 9:35 AM
Subject: Re: Time conversion...


> Hi, Vince.
>
> I don't think you're missing a thing. Nice, tight function.
>
> regards,
>
> Jim
>
> Vincegg at AOL.COM wrote:
> >
> > Hello,
> >
> > The code looks very convoluted.  Couldn't you just use something
like this or
> > am I missing something?
> >
> > function secs_to_mins(integer secs)
> > integer minutes
> >     minutes=floor(secs/60)
> >     return sprintf("%d:%02d",{minutes,floor(secs-minutes*60)})
> > end function
> >
> > Would that suffice?
> >
> > Vince
> >
>
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: Time conversion...

Whoa, wow, okay... I'm very impressed :)

Clearly the tightest fuction here was Jiris secs2mins function, blew 
my
mind away when I saw that all the fuctions that did it came out to do 
all
the same thing :) And look what it took me! Too many lines of code! 
Whee!

Anyway, thanx everyone for contributing, can we stick this into the 
EuSLP? (Eu Standard Libraries Project?)

Thanx all,

--"LEVIATHAN"

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu