NAME

Date::DateTime::Easy - Quickly and easily create a Date::DateTime object (by parsing almost anything)

VERSION

Version 0.020

SYNOPSIS

# Make Date::DateTime object for "now":
my $dt = Date::DateTime::Easy->new("today");

# Same thing:
my $dt = Date::DateTime::Easy->new("now");

# Uses Date::Manip's coolness:
my $dt = Date::DateTime::Easy->new("last monday");

# ... but in 1969:
my $dt = Date::DateTime::Easy->new("last monday", year => 1969);

# ... at the 100th nanosecond:
my $dt = Date::DateTime::Easy->new("last monday", year => 1969, nanosecond => 100);

# ... in EST: (This will NOT do a timezone conversion)
my $dt = Date::DateTime::Easy->new("last monday", year => 1969, nanosecond => 100, timezone => "US/Eastern");
ok($dt);

# This WILL do a proper timezone conversion:
my $dt = Date::DateTime::Easy->new("last monday", year => 1969, nanosecond => 100, timezone => "US/Pacific");
$dt->set_time_zone("US/Eastern");

DESCRIPTION

Date::DateTime::Easy makes Date::DateTime object creation quick and easy. It uses Date::Manip::ParseDate to parse almost anything you can throw at it.

METHODS

Date::DateTime::Easy->new( ... )

Date::DateTime::Easy->parse( ... )

Parse the given date/time specification using Date::Manip::ParseDate and use the result to create a Date::DateTime object. Returns a Date::DateTime object. Any timezone information from Date::Manip is ignored. To specify an explicit timezone, pass a timezone parameter through.

You can pass the following in:

parse       # The string for DateManip to parse via ParseDate
year        # A year to override the result of parsing
month       # A month to override the result of parsing
day         # A day to override the result of parsing
hour        # A hour to override the result of parsing
minute      # A minute to override the result of parsing
second      # A second to override the result of parsing
truncate    # A truncation parameter (e.g. year, day, month, week, etc.)
timezone    # A timezone (e.g. US/Pacific, UTC, etc.)
            # Either time_zone or timezone will work, but "time_zone" has precedence

... and anything else that you want to pass to the DateTime->new constructor

If truncate is specificied, then DateTime->truncate will be run after object creation.

Furthermore, you can simply pass the value for "parse" as the first positional argument of the Date::DateTime::Easy call, e.g.:

# This:
Date::DateTime::Easy->new("today", year => 2008, truncate => "hour");

# ...is the same as this:
Date::DateTime::Easy->new(parse => "today", year => 2008, truncate => "hour");

Also, =head1 EXPORT

parse( ... )

parse_date( ... )

parse_datetime( ... )

datetime( ... )

new_date( ... )

new_datetime( ... )

Same syntax as above. See above for more information.

MOTIVATION

Although I really like using Date::DateTime for date/time handling, I was often frustrated by its inability to parse even the simplest of date/time strings. There does exist a wide variety of Date::DateTime::Format::* modules, but they all have different interfaces and different capabilities. Coming from a Date::Manip background, I wanted something that gave me the power of ParseDate while still returning a Date::DateTime object. Most importantly, I wanted explicit control of the timezone setting at every step of the way. Date::DateTime::Easy is the result.

SEE ALSO

Date::DateTime, Date::Manip

AUTHOR

Robert Krimen, <rkrimen at cpan.org>

BUGS

Please report any bugs or feature requests to bug-datetime-easy at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Date-DateTime-Easy. 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 Date::DateTime::Easy

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2007 Robert Krimen, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.