Myco::Util::DateTime - a Myco utility class
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.
A simple shell to store oft-used Date-munging routines.
$datetime->date('YYYY-MM-DD');
Get the current date, in several formats: YYYY-MM-DD, YY-MM-DD, MM-DD-YYYY, MM-DD-YY.
my $year = $datetime->year;
Get the current year.
my $month = $datetime->month;
Get the current Month.
my $day = $datetime->day;
Get the current day of the month.
$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.
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.
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.
To install Myco, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Myco
CPAN shell
perl -MCPAN -e shell install Myco
For more information on module installation, please visit the detailed CPAN module installation guide.