Very interesting! Useless, but interesting! Chris
On Fri, Apr 13, 2012 at 8:04 AM, Curt Lundgren <[email protected]> wrote: > I was inspired to write a short Perl script this morning: > > #! /usr/bin/perl -w > use strict; > use Time::Local; > > # Restrict years to the Unix epoch > my $start_year = 1970; > my $end_year = 2037; > my $count = 0; > > my $year; > my $month; > my @mon = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); > > sub try_month { > my $month = shift; > my $year = shift() - 1900; > my $time = timelocal( 0, 0, 1, 13, $month, $year ); > my @test = localtime( $time ); > # Is the 13th on a Friday? > if( $test[6] == 5 ) { > print "$mon[$month] "; > $count++; > } > } # end try_month > > for( $year = $start_year; $year <= $end_year; $year++ ) { > print "$year "; > for( $month = 0; $month < 12; $month++ ) { > try_month( $month, $year ); > } > print "\n"; > } > print "Total $count\n"; > > Today is the second Friday the 13th of three that will occur this year. > What I learned from running this script: > > - Every year has at least one Friday the 13th > - Friday the 13th can occur in any month of the year > - When there are three '13ths' in a year they either occur in > February/March/November or January/April/July > - Jan/Apr/Jul '13ths' only happen in a leap year and Feb/Mar/Nov only > happen in non leap years > > Curt > > -- > You received this message because you are subscribed to the Google Groups > "NLUG" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nlug-talk?hl=en > -- You received this message because you are subscribed to the Google Groups "NLUG" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en
