in reply to Date conversion with Class::DBI
In the above example, you tell Class::DBI that the field__PACKAGE__->has_a( startdate => 'Date::Class', inflate => sub { Date::Class->new(shift) }, deflate => 'some_method_name' );
Incorrect:
SomeTab->create({startdate => '07/08/03'});
Correct:
SomeTab->create({startdate => Date::Class->new('07/08/03')});
The deflate value if present is the name of a method of
the Date::Class object that will return a string of
the proper format for insertion into the database.
Or if Date::Class objects will stringify properly you
may leave the deflate key out all together.
We struggled with this for quite some time
only after reading through the Class::DBI code did I
come to this conclusion, as it is very poorly documented
One thing to note, you should replace Date::Class with
some real class which deals with dates.
For our purposes I used Date::EzDate, as it seemed to
easily support the most formats for parsing input
I subclassed Date::EzDate to get the default ouput
format that we needed to work.
I hope this helps if you need further assistance please
contact me, mgrubb-web-perlmonks at fifthvision dot net
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Date conversion with Class::DBI
by cees (Curate) on Jul 09, 2003 at 22:19 UTC |