Day of the week: Difference between revisions

perl
(moved python)
(perl)
Line 165:
25 Dec 2118 is Sunday
</pre>
 
=={{header|Perl}}==
 
<perl>#! /usr/bin/perl -w
 
use Time::Local;
use strict;
 
for(my $i=2008; $i < 2121; $i++)
{
my $time = timelocal(0,0,0,25,11,$i);
my ($s,$m,$h,$md,$mon,$y,$wd,$yd,$is) = localtime($time);
if ( $wd eq 0 )
{
print "25 Dec $i is Sunday\n";
}
}
 
exit 0;</perl>
 
Output:
 
<pre>
25 Dec 2011 is Sunday
25 Dec 2016 is Sunday
25 Dec 2022 is Sunday
25 Dec 2033 is Sunday
Day too big - 25195 > 24855
Sec too small - 25195 < 78352
Sec too big - 25195 > 15247
Cannot handle date (0, 0, 0, 25, 11, 2038) at ./ydate.pl line 8
</pre>
 
I suppose there's a CPAN package that handles dates without relying on hardware/implementation dependent sizes (the Perl code basically seems to use the same functions used by C code)
 
 
=={{header|Python}}==