I'm proposing a module named "Date::FromToday".

It is used to calculate the date in the future/past from the localtime
the object was created.  I use it for calculating file names based off
of timespan from today.  Does this namespace look valid?


Simple usage with defaults
my $date = Date::FromToday->new( move => -1 );
my $date_string = $date->date_string;
#  $date_string = '03_26_2011'



#  usage with defaults exposed
my $date = Date::FromToday->new(
    move => -1,  # get yesterday's date
    leading_zeros => 1, # add a leading zero to the month and day, default = 1
    date_string_format => '{Y}-{M}-{D}', # formats day as 2011-Mar-27,
default = {M}_{D}_{Y}
    year_digits => 4, #  show year as 2011, not 11.  Default = 4
    month_translator => [qw{ Jan Feb Mar April May June July Aug Sept
Oct Nov Dec} ],  #translate months from array default = undef
    # force_date => '01_01_2000' # used to force todays date.
);

my $month = $date->month;
my $day = $date->day;
my $year = $date->year;
my $date_string = $date->date_string;

Reply via email to