Still trying to coerce numbers and strings for date math

and still going crazy…

I have tried everything I can think of…

interval
=> 1

dinc
=> “year”

interval.to_s + “.” + dinc
=> “1.year”

test = Time.now + (interval.to_s + “.” + dinc)
TypeError: no implicit conversion to float from string
from (irb):263:in `+’
from (irb):263
from :0

crap…that doesn’t work, nor does this…

(interv.to_s + “.” + dinc).to_f
=> 1.0

I have to have ‘interval’ be a number that I can increment while I test
it and ‘dinc’ to be the value (i.e., month, year) and reconstitute them.

How does one do this?

Craig

On 26 Feb 2008, at 17:58, Craig W. wrote:

=> “1.year”

I have to have ‘interval’ be a number that I can increment while I
test
it and ‘dinc’ to be the value (i.e., month, year) and reconstitute
them.

I suppose the key here is understanding that year/month etc… are
just methods on the integers, so
interval = 1
inc = ‘year’
test = Time.now + interval.year
test = Time.now + interval.send(inc)

Fred

On Tue, 2008-02-26 at 18:03 +0000, Frederick C. wrote:

dinc

interval = 1
inc = ‘year’
test = Time.now + interval.year
test = Time.now + interval.send(inc)


bing!

Thanks, I don’t know that I would have ever figured this out by myself.

Craig