NAME
Myco::Util::DateTime - a Myco utility class
SYNOPSIS
use Myco::Util::DateTime;
# No constructor is offered here - just use the class methods offered,
# but if this helps you...
my $datetime = 'Myco::Util::DateTime';
print "April Fools!" if $datetime->date('YYYY-MM-DD') eq '2006-04-01';
# Lot's of other neat methods - see below.
DESCRIPTION
A simple shell to store oft-used Date-munging routines.
CLASS METHODS
date
$datetime->date('YYYY-MM-DD');
Get the current date, in several formats: YYYY-MM-DD, YY-MM-DD, MM-DD-YYYY, MM-DD-YY.
year
my $year = $datetime->year;
Get the current year.
month
my $month = $datetime->month;
Get the current Month.
day
my $day = $datetime->day;
Get the current day of the month.
date_add
$datetime->date_add($offset, $date1);
Adds an integer (positive or negative) offset to a given date. If no date is given, then the current date is used.
date_range
my @range = $datetime->date_range('2002-06-01', '2003-06-01');
or
my @range = $datetime->date_range(-365, '2003-06-01');
or
my @range = $datetime->date_range(-365);
Returns the range of dates between two given dates (including both). Alternatively, adds an integer (positive or negative) offset to a given date and returns an array of dates for each intervening day. Starts with the most recent, and descends or ascends from there. If no date is given, the current date is used.
american
my @american_dates = $datetime->american( @dates );
my $isa_american_date = $american_dates[0] eq 'June 16th, 2003';
Translates ISO-format dates into an American-style dates.