maZZoo maZZoo's blog
very low frequency tech postings  -   07 03 2005
    home
    blog
    feed
    eyes
    info

    code [12]
    dect [4]
    hard [8]
    meta [5]
    security [5]

jul 2009 (1)
jun 2009 (1)
jan 2009 (2)
dec 2008 (1)
oct 2008 (1)
jan 2008 (1)
oct 2007 (1)
jun 2007 (1)
feb 2007 (3)
jan 2007 (3)
nov 2006 (2)
aug 2006 (2)
jul 2006 (1)
may 2006 (1)
nov 2005 (2)
oct 2005 (1)
apr 2005 (2)
mar 2005 (2)
feb 2005 (1)
jan 2005 (1)
may 2004 (1)
jan 2004 (1)
apr 2003 (1)
jan 2003 (1)

Mon, 07 Mar 2005

oldcalendar.pl

in the listed years you can use old calendars from the years printed on the right:

$ ./oldcalendar.pl 2005 2020 100
2005 :  1994 1983 1977 1966 1955 1949 1938 1927 1921 1910
2006 :  1995 1989 1978 1967 1961 1950 1939 1933 1922 1911
2007 :  2001 1990 1979 1973 1962 1951 1945 1934 1923 1917 1906
2008 :  1980 1952 1924
2009 :  1998 1987 1981 1970 1959 1953 1942 1931 1925 1914
2010 :  1999 1993 1982 1971 1965 1954 1943 1937 1926 1915 1909
2011 :  1994 1983 1977 1966 1955 1949 1938 1927 1921 1910
2012 :  1984 1956 1928
2013 :  2002 1991 1985 1974 1963 1957 1946 1935 1929 1918 1907
2014 :  2003 1997 1986 1975 1969 1958 1947 1941 1930 1919 1913
2015 :  1998 1987 1981 1970 1959 1953 1942 1931 1925 1914
2016 :  1988 1960 1932
2017 :  1995 1989 1978 1967 1961 1950 1939 1933 1922 1911
2018 :  2001 1990 1979 1973 1962 1951 1945 1934 1923 1917 1906
2019 :  2002 1991 1985 1974 1963 1957 1946 1935 1929 1918 1907
2020 :  1992 1964 1936 1908
sourcecode:

#!/usr/bin/perl -w

# oldcalendar.pl [startyear] [endyear] [recentyears]
#
# prints out the years of old calenders you could use
# in startyear (def=2005) through endyear (def=2010)
# considering calenderyears [startyear-recentyears .. startyear-1]
#
# (c) 2005 Matthias Wenzel


use strict;

sub weekday($$$){
	my ($day, $month, $year) = @_;
	# see
	# http://www.tondering.dk/claus/cal/node3.html#SECTION00360000000000000000
	my $a = int( (14 - $month) / 12 );
	my $y = $year - $a;
	my $m = $month + 12 * $a - 2;
	my $d = ( $day + $y + int($y / 4) - int($y / 100) + int($y / 400) + 31 * int($m / 12) ) % 7;
	return $d;
}

my $start = 2005;
my $end   = 2010;
my $old   =   50; # dump $start - $old calenderyears

$start    = $ARGV[0] if $ARGV[0];
$end      = $ARGV[1] if $ARGV[1];
$old      = $ARGV[2] if $ARGV[2];

$end = $start if $start > $end;

my $curr=$start;
while ($curr <= $end){
	print $curr . " : ";
	my $o = $start - 1;
	while ($o ne ($start - $old)){
		if (( weekday(1,1,$curr) eq weekday(1,1,$o) ) & ( weekday(31,12,$curr) eq weekday(31,12,$o) )){
			print " " . $o;
		}
		$o--;
	}
	$curr++;
	print "\n";
}



posted in /code  |  link  |  comments [0]   


validate HTML