| Date-ISO documentation | view source | Contained in the Date-ISO distribution. |
Date::ISO - Perl extension for converting dates between ISO and Gregorian formats.
use Date::ISO;
$iso = Date::ISO->new( iso => $iso_date_string );
$iso = Date::ISO->new( epoch => $epoch_time );
$iso = Date::ISO->new( ical => $ical_string );
$iso = Date::ISO->new( year => $year, month => $month,
day => $day );
$iso = Date::ISO->new( year => $year, week => $week,
weekday => $weekday );
$year = $iso->year;
$iso_week = $iso->iso_week;
$week_day = $iso->iso_week_day;
$month = $iso->month;
$day = $iso->day;
And, for backward compatibility:
($yearnumber, $weeknumber, $weekday) = iso($year, $month, $day);
($yearnumber, $weeknumber, $weekday) = localiso(time);
($year, $month, $day) = inverseiso($iso_year, $iso_week,
$iso_week_day);
Convert dates between ISO and Gregorian formats.
my $iso = Date::ISO->new( iso => $iso_date_string );
my $iso = Date::ISO->new( epoch = $epoch_time );
Set the time to 2:30:25 on the date specified in $iso_date_string my $iso = Date::ISO->new( iso => $iso_date_string, hour => 2, min => 30, sec => 25 );
And, since this is a Date::ICal subclass ...
my $iso = Date::ISO->new( ical => $ical_string );
$ical = $iso->ical;
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.
The following functional interface is provided for backwards compatibility with former versions.
$iso = iso($year, $month, $day);
Rich Bowen (rbowen@rcbowen.com)
$Date: 2003/01/21 15:36:59 $
For more information about this calendar, please see:
http://personal.ecu.edu/mccartyr/ISOwdALG.txt
http://personal.ecu.edu/mccartyr/isowdcal.html
http://personal.ecu.edu/mccartyr/aboutwdc.htm
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
http://www.fourmilab.ch/documents/calendar/
Finally, many many many thanks to Rick McCarty who provided me with the algorithms that I'm using for conversions to and from ISO dates. All the errors in previous versions of this module were entirely my fault for miscopying something from his algorithm.
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.
Creating a Date::ISO object with an ISO string, and then immediately getting the ISO string representation of that object, is not giving back what we started with. I'm not at all sure what is going on.
$Log: ISO.pm,v $
Revision 1.30 2003/01/21 15:36:59 rbowen
Patch submitted by Winifred Plapper for a stupid typo.
Revision 1.29 2002/11/08 12:57:28 rbowen
Patch by Martijn van Beers to make it possible to construct objects with
a week number and week day, as per the spec.
Revision 1.28 2002/01/21 02:13:57 rbowen
Patch from Jesse Vincent, to permit the setting of times in ISO dates.
Revision 1.27 2001/11/29 18:03:16 rbowen
If offsets are not specified, use GMT. This fixes a problem that has
been in the last several releases. Need to add additional tests to test
in the system's local time zone.
Revision 1.26 2001/11/28 22:36:42 rbowen
Jesse's patch to make offsets work as passed in, rather than setting to
0.
Revision 1.25 2001/11/27 02:44:43 rbowen
If an offset is not provided, explicitly set to 0. We are dealing with
dates, not times.
Revision 1.24 2001/11/27 02:15:15 rbowen
Explicitly set offset to 0 always.
Revision 1.23 2001/11/25 03:55:23 rbowen
Code fold. Nothing to see here.
Revision 1.22 2001/11/24 16:03:11 rbowen
Offsets must be explicitly set to 0 in order to get the right epoch
time. See Date::ICal for details
Revision 1.21 2001/09/12 03:21:31 rbowen
remove warnings for 5.005 compatibility
Revision 1.20 2001/08/23 02:04:00 rbowen
Thanks to Rick McCarty, conversions from ISO to gregorian are now
working correctly. They never worked correctly in earlier versions.
All of the tests have been updated to use is() rather than ok() so
that I could actually see what was failing. Schwern++
Revision 1.19 2001/07/30 00:50:07 rbowen
Update for the new Date::ICal
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.
| Date-ISO documentation | view source | Contained in the Date-ISO distribution. |