[Dbix-class] Pointless update on a date field
Jonathan Rockway
jon at jrock.us
Thu Sep 13 17:03:49 GMT 2007
Richard Jones wrote:
> There is obviously something amiss because if I omit my own
> date_to_mysql() method then system tries to retrieve dates in
> dd/mm/yyyy format. =
I think you're misunderstanding InflateColumn::DateTime. Here's some
example code:
$some_rs->create({ creation_time =3D> DateTime->now });
As you can see, I never do any string manipulation with the date. I get
a DateTime object, and put it in the database. The other details are
handled by the deflation.
If you want to put EU-formatted dates into your database, the idea is
exactly the same. You use the EU-formatted date to get a DateTime
object (via a DateTime::Format), then you just put the DateTime object
into the database (and you get one back out when you query for it). The
fact that a date was specially formatted is only known momentarily.
Once you have a DateTime object, it's just a date and time.
I'm not sure about the details of the parsing though... I'm a dumb
American so it's never occurred to me to parse non-US dates :)
DateTime::Format is the namespace for parsers, though, so I guess you
should look there.
Hope this helps.
Regards,
Jonathan Rockway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 370 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070913/04=
85569d/signature.pgp
More information about the DBIx-Class
mailing list