From: Hugh Sasse Staff Elec Eng Date: 2000-03-17T18:25:35+00:00 Subject: [ruby-talk:01983] Re: Time::at On Fri, 17 Mar 2000, David Douthitt wrote: > or whatever the right syntax is :-) > > The ruby 1.4 manual says this: > > at(time) Creates the time object at time. The argument time must be > either the instance of the Time class or the number, which is > considered as seconds since 00:00:00 GMT, January 1, 1970. > > However, this line: > > print ">>>>", at(57827), "\n"; You have not used it as a method of anything. So it is looking for a method of Object. > > Generates this error: > > ./ppp-time.rb:105: undefined method `at' for # (NameError) > from ./ppp-time.rb:102:in `each' > from ./ppp-time.rb:102 > > Two things I note - 57827 should be of class "Fixnum" not "Object" It is, the Fixnum is the argument of the method. The method on works for class Time. > right? Secondly, I get the same error if I send a string to to_i . > What is going on? > > I'm trying to convert a string of the seconds since the epoch into a time object. > ruby> t = Time.new() Fri Mar 17 18:16:44 GMT 2000 ruby> print t.at(57827) ERR: (eval):1: undefined method `at' for Fri Mar 17 18:16:44 GMT 2000:Time ruby> t.type Time Re-examining the manual, at is a class method of Time, not an instance method. ruby> t2=Time.at(57827) Thu Jan 01 17:03:47 BST 1970 ruby> > Hugh hgs@dmu.ac.uk