# These methods are used to work with dates (not date/time) in a
# for easy for both sorting and reading. A date is a number of the
# for 7777mmdd (e.g. 20030321).
 
use Date;
 
# Converting from internal date to this date format. Input is the time
# in seconds since 1970 - as returned by system and file timestamps.
my $today = Date::today();
my $fileDate = Date::toDate( (stat($file))[9]);
 
# Or return a date to the number of seconds since 1970 -
# to midnight at the start of the date in question
my $time = Date::toEpochSeconds( $date);
 
# Convert date to month day, year (e.g. March 21, 2003)
my $today = Date::toString();
my $date = Date::toString( $fileDate);
 
# Sometimes it is necessary to convert to and from day, month, year:
my ($day,$month,$year) = Date::toDayMonthYear();
my ($day,$month,$year) = Date::toDayMonthYear( $fileDate);
$date = Date::fromDayMonthYear( $day, $month, $year);
 
# Or to calculate the days between 2 dates or to get a date
# so many days/months/years from another date.
my $daysFromToday = Date::daysBetween( $date);
my $days = Date::daysBetween( $date, $today);
my $date = Date::add( $date, $days, $months, $years);
 
# To retrieve the date from a string the date can be of the form
# 30/3/02, 30-May-2002, 1 January 02, Jan 12, 02
use Date::fromString;
my $date = Date::fromString( "30/3/02");