Time.to_s

I'm overriding Time.to_s to use a custom date format.
The method get's an argument, nothing in the documentation says that it
should. How do I find out what the argument does?
Where can I find the sourcecode for the original Time.to_s?

···

--
Posted via http://www.ruby-forum.com/.

Hmm that is strange, I cannot pass any argument to Time#to_s, can you
specify your version?
Robert

···

On 7/1/07, Jonas <rails@gauffin.org> wrote:

I'm overriding Time.to_s to use a custom date format.
The method get's an argument, nothing in the documentation says that it
should.

--
I always knew that one day Smalltalk would replace Java.
I just didn't know it would be called Ruby
-- Kent Beck

Hi Jonas,

the Object.to_s method should not expect an argument since it is per
default an alias for Object.name.

If you want a custom time format you should overwrite the instance
method. There are several ways to accomplish this. For example you
derive from Time:

class CustomTime < Time
  def to_s
    strftime 'Simon says: Do your %d sit-ups on every %A.'
  end
end

HF
Florian

Try Time#strftime
(string format time)
It is similar to the formatting found in other languages. You can define your own method and simply use part of this internally in you method:

def my_time_format(Time)
     Time.strftim(%D%M)
      ...other code...
end

It is really that simple.

···

On Jul 1, 2007, at 5:40 AM, Florian Aßmann wrote:

Hi Jonas,

the Object.to_s method should not expect an argument since it is per
default an alias for Object.name.

If you want a custom time format you should overwrite the instance
method. There are several ways to accomplish this. For example you
derive from Time:

class CustomTime < Time
  def to_s
    strftime 'Simon says: Do your %d sit-ups on every %A.'
  end
end

HF
Florian