NAME

MongoDBx::Class::ParsedAttribute::DateTime - An automatic DateTime parser for MongoDBx::Class document classes

VERSION

version 1.030002

SYNOPSIS

        # in one of your document classes
        has 'datetime' => (is => 'ro', isa => 'DateTime', traits => ['Parsed'], required => 1);

DESCRIPTION

This 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.

ATTRIBUTES

f

A DateTime::Format::W3CDTF object used for expanding/collapsing. Automatically created.

CLASS METHODS

new()

Creates a new instance of this module.

OBJECT METHODS

expand( $str )

Converts a W3C datetime string to DateTime object.

collapse( $dt )

Converts a DateTime object to a W3C datetime string.

AUTHOR

Ido Perlmuter, <ido at ido50.net>

BUGS

Please 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.

SUPPORT

You can find documentation for this module with the perldoc command.

        perldoc MongoDBx::Class::ParsedAttribute::DateTime

You can also look for information at:

SEE ALSO

MongoDBx::Class::EmbeddedDocument.

LICENSE AND COPYRIGHT

Copyright 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.