Re: Returning A Class::Date Object

[prev] [thread] [next] [Date index for 2005/01/10]

From: Matt S Trout
Subject: Re: Returning A Class::Date Object
Date: 21:23 on 10 Jan 2005
On Mon, Jan 10, 2005 at 09:10:19PM +0000, Jay Hargreaves wrote:
> Hi y'all!
> 
> I have found Class::Date to be a very useful date formatting routine and 
> as such I would like to return a Class::Date object (rather than the 
> actual value) for any date fields in my database.
> 
> Presumably it might also be a good idea to set values in the database 
> from a Class::Date object, since it has various parsing facilities 
> available.
> 
> Can someone please tell me a good way to do this is? Do I use a trigger? 

Have a look at the inflate and deflate stuff in the Class::DBI pod, which
expands on the following synopsis example:

Music::CD->has_a(
  reldate => 'Time::Piece',
  inflate => sub { Time::Piece->strptime(shift, "%Y-%m-%d") },
  deflate => 'ymd',
);

        -- 
        Bring me my etherkiller; Oh clouds unfold! / Bring me the magic smoke of desire
I shall not cease from mental fight / Nor shall my LART rest in my hand
Till we have buried the bodies / Of all the lusers in all this land
  -- rpg, ASR                        [ My homepage is http://www.trout.me.uk/ ]

Returning A Class::Date Object
Jay Hargreaves 21:10 on 10 Jan 2005

Re: Returning A Class::Date Object
Matt S Trout 21:23 on 10 Jan 2005

Re: Returning A Class::Date Object
Jay Hargreaves 09:37 on 11 Jan 2005

Generated at 12:15 on 16 Jan 2005 by mariachi v0.52