Hi,
Time.today fails on my server and works on my dev machine, both run
Rails 2.3.3. What’s going on?
Hi,
Time.today fails on my server and works on my dev machine, both run
Rails 2.3.3. What’s going on?
2009/8/28 Fernando P. [email protected]:
Hi,
Time.today fails on my server and works on my dev machine, both run
Rails 2.3.3. What’s going on?
Are you sure you are not confusing it with Date.today? I was not
aware that there is a Time.today. There is a Time.now.
Colin
Are you sure you are not confusing it with Date.today? I was not
aware that there is a Time.today. There is a Time.now.Colin
On my dev Machine:
$ ./script/console
Loading development environment (Rails 2.3.3)
Time.now
=> Fri Aug 28 22:51:16 0200 2009Time.today
=> Fri Aug 28 00:00:00 0200 2009
I do admit there is a problem with the time returned, but still the
method call worked.
On Aug 28, 4:56 pm, Fernando P. [email protected]
wrote:
Hi,
Time.today fails on my server and works on my dev machine, both run
Rails 2.3.3. What’s going on?Posted viahttp://www.ruby-forum.com/.
Whats are the respective Ruby versions? Time.today exists on 1.8.7,
but not 1.9.1 (or 1.8.6 to my knowledge)
Time.today exists on 1.8.7,
but not 1.9.1 (or 1.8.6 to my knowledge)
Damn that’s the answer!
You can do something like this (utilizing a Rails time method):
class Time
def self.today
Time.now.beginning_of_day
end
end
Time.today
=> Mon Aug 31 00:00:00 +1200 2009
Regards
Kieran
On Aug 29, 8:24 pm, Fernando P. [email protected]
Date.today is part of Ruby standard library (not added by Rails).
jeremy
2009/8/30 Maurício Linhares [email protected]:
Time has no today method, today is a Date method added by rails, as in
Date.today.
The method that looks like the same in time is Time.now.
Maurício Linhares
http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr
Hi, here’s my results for the various Ruby implementations:
Ruby 1.8.6:
Time.now
=> Sun Aug 30 13:49:32 -0700 2009Time.today
NoMethodError: undefined method `today’ for Time:Class
from (irb):2Date.today
=> Sun, 30 Aug 2009quit
Ruby 1.8.7:
Time.now
=> 2009-08-30 13:51:31 -0700Time.today
NoMethodError: undefined methodtoday' for Time:Class from (irb):2 from /opt/local/bin/irb:12:in
’quit
Ruby 1.9.1:
Time.now
=> 2009-08-30 13:54:31 -0700Time.today
NoMethodError: undefined methodtoday' for Time:Class from (irb):2 from /opt/local/bin/irb:12:in
’quit
Good luck,
-Conrad
On Aug 30, 4:57 pm, Conrad T. [email protected] wrote:
NoMethodError: undefined method `today’ for Time:Class
NoMethodError: undefined method
today' for Time:Class from (irb):2 from /opt/local/bin/irb:12:in
’quit
Good luck,
-Conrad
What does the RUBY_VERSION say?
It looks like you accidentally ran the wrong IRB when testing this
out, as your Ruby “1.8.7” and 1.9.1 are both the same executable (/opt/
local/bin/irb).
But Keiran’s suggestion isn’t bad, might want to work a
method_defined? in with that though.
Hi, it’s actually two different machines.
-Conrad
On Aug 30, 5:08 pm, pharrington [email protected] wrote:
=> Sun Aug 30 13:49:32 -0700 2009>> Time.today
Time.now
Good luck,
method_defined? in with that though.
And this is me speaking apparently too soon
from my laptop (Kubuntu 9.03)
irb(main):006:0> RUBY_VERSION
=> “1.8.7”
irb(main):007:0> Time.today
NoMethodError: undefined method `today’ for Time:Class
from (irb):7
irb(main):008:0>
from my desktop (also Kubuntu 9.03)
RUBY_VERSION
=> “1.8.7”Time.today
=> Sun Aug 30 00:00:00 -0400 2009
So a gem must be adding this somewhere, I’m too lazy to look where
right now though
As someone told me before, I need to Google more :\
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs