Date::FromToday - Calculate the date in the past or future X days from today
Version 0.05
Date::FromToday is a Perl module for calculating a date in the past or future X number of days from today. It allows for custom formatting of the date string with month/day/year placement, seperators, leading zeros, month translation, forcing today's date, number of digits in the year.
Date::FromToday
use Date::FromToday; my $date = Date::FromToday->new( move => -1 ); # prints yesterdays date in MM_DD_YYYY print $date->date_string;
-or-
my $date = Date::FromToday->new( move => -1, month_translator => [ qw( Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec ), ], date_string_format => '{M}.{D}.{Y}', leading_zeros => 0, year_digits => 2, ); # prints yesterday's date looking like Jan.1.11 print $date->date_string;
Creates and returns Date::FromToday object.
my $date = Date::FromToday->new( move => -1 );
Here are the parms for Date::FromToday
move => $days_to_add_or_subtract
Adds or subtracts days to the current date. Negative numbers move back in time, positive move into future. Required.
date_string_format => {M}_{D}_{Y}
Decides on how to format the date_string method. M will be replaced by the Month, D with the Day, and Y with the Year. The delimiter is also configureable, M*D^Y = 12*31^2021
leading_zeros => [0|1]
Determines if leading zeros will be added. Default = 1 which means it will be done.
month_translator => $month_names_list_ref
Determines how the month will be displayed: month_translator => [ qw( Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec ), ],
force_today => MM_DD_YYYY
You can also force the current date. Must be in MM_DD_YYYY format.
year_digits => [1|2|3|4]
Specifies the number of digits in the year: 4 ~ 1895 3 ~ 895 2 ~ 95 1 ~ 5
Returns the calculated day, either numeric or translated from
Returns the calculated month
Returns the calculated year
Returns the date in a string as specified by the 'date_sting_format' param.
Adam Wohld, <adam at spatialsystems.org>
<adam at spatialsystems.org>
Please report any bugs or feature requests to bug-date-fromtoday at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Date-FromToday. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-date-fromtoday at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Date::FromToday
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-FromToday
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Date-FromToday
CPAN Ratings
http://cpanratings.perl.org/d/Date-FromToday
Search CPAN
http://search.cpan.org/dist/Date-FromToday/
Copyright 2011 Adam Wohld.
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.
To install Date::FromToday, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::FromToday
CPAN shell
perl -MCPAN -e shell install Date::FromToday
For more information on module installation, please visit the detailed CPAN module installation guide.