NAME
Date::ISO - Perl extension for converting dates between ISO and Gregorian formats.
SYNOPSIS
use Date::ISO;
($yearnumber, $weeknumber, $weekday) = iso($year, $month, $day);
Note that year and month here are as given by localtime, not as given by a calendar. Hence, January 1, 2001 is (101, 0, 1). This is probably undesired behavior, and may be changed in a future release.
($yearnumber, $weeknumber, $weekday) = localiso(time);
($year, $month, $day) = inverseiso($iso_year, $iso_week, $iso_week_day);
Or, using the object interface:
use Date::ISO qw();
my $iso = Date::ISO->new( ISO => $iso_date_string );
$iso_year = $iso->iso_year;
$year = $iso->year;
$iso_week = $iso->iso_week;
$week_day = $iso->iso_week_day;
$month = $iso->month;
$day = $iso->day;
DESCRIPTION
Convert dates between ISO and Gregorian formats.
iso
($year, $week, $day) = iso($year, $month, $day);
($year, $week, $day) = iso(2001, 4, 28); # April 28, 2001
Returns the ISO year, week, and day of week, when given the (Gregorian) year, month, and day.
Note that years are full 4 digit years, and months are numbered with January being 1.
inverseiso
($year, $month, $day) = inverseiso($year, $week, $day);
Given an ISO year, week, and day, returns year, month, and day, as localtime would give them to you.
localiso
($year, $week, $day) = localiso(time);
Given a time value (epoch time) returns the ISO year, week, and day.
OO interface
The OO interface allows you to create a date object, and determime from it the various attributes in the ISO calendar (the year, week, and day of that week) and in the Gregorian reckoning (the year, month, and day).
new
my $iso = Date::ISO->new( ISO => $iso_date_string );
or ...
my $iso = Date::ISO->new( EPOCH = $epoch_time );
Accepted ISO date string formats are:
1997-02-05 (Feb 5, 1997)
19970205 (Same)
199702 (February 1997)
1997-W06 (6th week, 1997)
1997W06 (Same)
1997-W06-2 (6th week, 2nd day)
1997W062 (Same as above)
1997-035 (35th day of 1997)
1997035 (Same as above)
2-digit representations of the year are not supported at this time.
Time values are not supported at this time.
AUTHOR
Rich Bowen (rbowen@rcbowen.com)
DATE
$Date: 2001/07/24 16:08:11 $
Additional comments
For more information about this calendar, please see:
http://personal.ecu.edu/mccartyr/ISOwdALG.txt
http://personal.ecu.edu/mccartyr/isowdcal.html
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
To Do
Need to flesh out test suite some more. Particularly need to test some dates immediately before and after the first day of the year - days in which you might be in a different Gregorian and ISO years.
ISO date format also supports a variety of time formats. I suppose I should accept those as valid arguments.
Need methods to output epoch time, and a variety of valid ISO date strings, from a Date::ISO object.
Version History#{{{
$Log: ISO.pm,v $
Revision 1.18 2001/07/24 16:08:11 rbowen
perltidy
Revision 1.17 2001/04/30 13:23:35 rbowen
Removed AutoLoader from ISA, since it really isn't.
Revision 1.16 2001/04/29 21:31:04 rbowen
Added new tests, and fixed a lot of bugs in the process. Apparently the
inverseiso function had never actually worked, and various other functions
had some off-by-one problems.
Revision 1.15 2001/04/29 02:42:03 rbowen
New Tests.
Updated MANIFEST, Readme for new files, functionality
Fixed CVS version number in ISO.pm
Revision 1.14 2001/04/29 02:36:50 rbowen
Added OO interface.
Changed functions to accept 4-digit years and 1-based months.