[#3006] CVS repository — "Eugene Scripnik" <hoaz@...>

Hello.

21 messages 2004/06/16
[#3008] Re: CVS repository — ts <decoux@...> 2004/06/16

>>>>> "E" == Eugene Scripnik <hoaz@gala.net> writes:

[#3009] Re: CVS repository — Michal Rokos <michal@...> 2004/06/16

Hi!

[#3057] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

Hi,

20 messages 2004/06/23

Re: Date.from_time

From: "Berger, Daniel" <djberge@...>
Date: 2004-06-14 19:51:15 UTC
List: ruby-core #2995
> -----Original Message-----
> From: Gavin Sinclair [mailto:gsinclair@soyabean.com.au] 
> Sent: Saturday, June 12, 2004 6:59 PM
> To: ruby-core@ruby-lang.org
> Subject: Date.from_time
> 
> 
> Folks,
> 
> At the moment, I don't see an easy way to create a Date or 
> DateTime object given a Time object.  That's something I need 
> to do at the moment, and it seems like it should be easy.
> 
> If I submit a patch to define Date.from_time, will it be 
> accepted?  Is there a preferred name?

Well, the Date class has a parse() method.  Unfortunately, it doesn't
seem able to parse stringified Time objects.  I think the ideal solution
is to make it understand so that this would be legal:

require "date"
t = Time.now
d = Date.new(Date.parse(t.to_s)[0..2]) # or whatever

That, or simply have the Date constructor understand Time objects and/or
stringified Time objects:

d = Date.new(t) # It would be nice if this DWIM.

I vote for this over adding a new method.

Just my .02.

Dan


In This Thread

Prev Next