
Date::Simple - a simple date object

my $date = Date::Simple->new('1972-01-17');
my $year = $date->year;
my $month = $date->month;
my $day = $date->day;
my $date2 = Date::Simple->new($year, $month, $day);
my $today = Date::Simple->new;
my $tomorrow = $today + 1;
print "Tomorrow's date (in ISO 8601 format) is $tomorrow.\n";
if ($tomorrow->year != $today->year) {
print "Today is New Year's Eve!\n";
}
if ($today > $tomorrow) {
die "warp in space-time continuum";
}
# you can also do this:
($date cmp "2001-07-01")
# and this
($date <=> [2001, 7, 1])

This module may be used to create simple date objects. It only handles dates within the range of Unix time. It will only allow the creation of objects for valid dates. Attempting to create an invalid date will return undef.

my $date = Date::Simple->new('1972-01-17');
my $otherdate = Date::Simple->new(2000, 12, 25);
The new method will return a date object if the values passed in specify a valid date. If an invalid date is passed, the method returns undef.

my $tomorrow = $today->next;
Returns an object representing tomorrow.
my $yesterday = $today->prev;
Returns an object representing yesterday.
my $year = $date->year;
Return the year of the date held in this date object
my $month = $date->month;
Return the month of the date held in this date object
my $day = $date->day;
Return the day of the date held in this date object
Returns a string representing the date, in the format specified. If you don't pass a parameter, an ISO 8601 formatted date is returned.
my $change_date = $date->format("%d %b %y");
my $iso_date1 = $date->format("%Y-%m-%d");
my $iso_date2 = $date->format;
The formatting parameter is similar to one you would pass to strftime(3). This is because we actually do pass it to strftime to format the date.

Some operators can be used with Date::Simple instances:

Marty Pauley <marty@kasei.com>

Copyright (C) 2001 Kasei
This program is free software; you can redistribute it and/or modify it
under the terms of either:
a) the GNU General Public License;
either version 2 of the License, or (at your option) any later version.
b) the Perl Artistic License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.