# in one of your document classes
has 'datetime' => (is => 'ro', isa => 'DateTime', traits => ['Parsed'], required => 1);
DESCRIPTIONThis class implements the MongoDBx::Class::ParsedAttribute role. It provides document classes with the ability to automatically expand and collapse DateTime values.
While the Perl MongoDB driver already supports DateTime objects natively, due to a bug with MongoDB, you can't save dates earlier than the UNIX epoch. This module overcomes this limitation by simply saving dates as strings and automatically turning them into DateTime objects (and vica-versa). The DateTime strings are formatted by the DateTime::Format::W3CDTF module, which parses dates in the format recommended by the W3C. This is good for web apps, and also makes it easier to edit dates from the MongoDB shell. But most importantly, it also allows sorting by date.
Note that if you already have date attributes in your database, you can't just start using this parser, you will first have to convert them to the W3C format.
fA DateTime::Format::W3CDTF object used for expanding/collapsing. Automatically created.
new()Creates a new instance of this module.
expand( $str )Converts a W3C datetime string to DateTime object.
collapse( $dt )Converts a DateTime object to a W3C datetime string.
AUTHORIdo Perlmuter, "<ido at ido50.net>"
BUGSPlease report any bugs or feature requests to "bug-mongodbx-class at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MongoDBx-Class>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORTYou can find documentation for this module with the perldoc command.
You can also look for information at:
- RT: CPAN's request tracker
- AnnoCPAN: Annotated CPAN documentation
- CPAN Ratings
- Search CPAN
LICENSE AND COPYRIGHTCopyright 2010-2014 Ido Perlmuter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.