Re: how do I convert a # to time?

"mulpinBR - 111.898.068 > http://br.xaraya.com" <xaraya-ZJ5JVcqp1wkXtBFVwdE/[email protected]>
Newsgroups gmane.comp.cms.xaraya.curiosa
Organization Xaraya News Server
Message-ID <[email protected]>
Well, the formating part works, but the math... I think needs some
tweaking.

I've got some times like:

1'43999999999998

0'5.6E+14

hmm... Lemme see if I got it correctly: explode made $minutes an
integer, right? then, when calculating, you have for instance
333333333/10*60, floor'ed to 33333333333 not 0.33333333/10*60, floored
to 1 (or whatever that returns)

right?

(...) ok, simply adding a $minutes = 0.$minutes did the trick.

So, here's what I came up with:

function ReadTime($readtxt) {
 $readspeed = CountWords($readtxt);
 $readtimeraw = $readspeed / 150;
 list($min,$secs) = explode('.',$readtimeraw);
 $secs = "0.$secs";
 $secs = floor(60*($secs/10));
 $readtime = "$min'$secs\"";
return($readtime);

which calculates the estimated reading time for a story, for PN.

Can it be tweaked for speed? I'm so bad at coding...

Thanks for the help!

X's,
Murilo


"Roger Raymond" <roger-vp4IRbjYgwNWk0Htik3J/[email protected]> escreveu na mensagem
news:[email protected]
| Bah! that math is totally wrong!!! sorry
|
| Should be.
|
| // convert the decimal minutes dropping any remainder
| $minutes = floor(60*($minutes/10));
|
|
| Roger Raymond wrote:
| > Probably could use come simple math.  Just get the two parts of
the
| > number...
| >
| >     // assuming the format will always be the same
| >     list($hours,minutes) = explode('.',$number);
| >
| >     // convert the decimal minutes dropping any remainder
| >     $minutes = floor(60 / $minutes);
| >
| >     $timeAsText = "$hours'$minutes\"";
| >
| > Hope that starts you on your way :)
| >
| > Roger
| >
| > mulpinBR - 111.898.068 > http://br.xaraya.com wrote:
| >
| >> I believe it's really easy, but late at night I can't figure it
out:
| >> how could I convert for instance 2.5 to 2'30"?
| >>
| >> X's,
| >> Murilo
| >>
| >>
| >> ---
| >>
| >> Checked by AVG anti-virus system (http://www.grisoft.com).
| >> Version: 6.0.509 / Virus Database: 306 - Release Date: 12/08/2003
| >>
| >>
| >
|


---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.