The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Date::FromToday - Calculate the date in the past or future X days from today

VERSION

Version 0.05

SYNOPSIS

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.

    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;

CONSTRUCTOR AND STARTUP

new()

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

METHODS

day

Returns the calculated day, either numeric or translated from

month

Returns the calculated month

year

Returns the calculated year

date_string

Returns the date in a string as specified by the 'date_sting_format' param.

AUTHOR

Adam Wohld, <adam at spatialsystems.org>

BUGS

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.

SUPPORT

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

    perldoc Date::FromToday

You can also look for information at:

LICENSE AND COPYRIGHT

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.