File: anniversaries.pl

package info (click to toggle)
libdate-pcalc-perl 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,436 kB
  • ctags: 540
  • sloc: perl: 16,700; ansic: 3,080; sh: 14; makefile: 4
file content (75 lines) | stat: -rwxr-xr-x 2,309 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!perl -w

###############################################################################
##                                                                           ##
##    Copyright (c) 2001 - 2009 by Steffen Beyer.                            ##
##    All rights reserved.                                                   ##
##                                                                           ##
##    This program is free software; you can redistribute it                 ##
##    and/or modify it under the same terms as Perl itself.                  ##
##                                                                           ##
###############################################################################

BEGIN { eval { require bytes; }; }
use strict;
no strict "vars";

use Date::Pcalc qw(:all);
use Date::Pcalendar;

# How many days in advance:

$Days = 90; # = roughly 3 months

$Anniversaries =
{
    "Spouse 1971"             =>  "30.12.",
    "Wedding Day 1992"        =>  "01.09.",
    "Valentine's Day"         =>  "14.02.",
    "Son Richard 1996"        =>  "11.05.",
    "Daughter Irene 1994"     =>  "17.01.",
    "Mom 1939"                =>  "19.08.",
    "Dad 1937"                =>  "23.04.",
    "Brother Timothy 1969"    =>  "24.04.",
    "Sister Catherine 1973"   =>  "21.10.",
    "Cousin Paul 1970"        =>  "16.10.",
    "Aunt Marjorie 1944"      =>  "09.06.",
    "Uncle George 1941"       =>  "02.08.",
    "Friend Alexander 1968"   =>  "12.06.",
};

$calendar = Date::Pcalendar->new( $Anniversaries );

@date = Today();

for ( $delta = 0; $delta <= $Days; $delta++ )
{
    if ($calendar->is_full(@date) and
        ((@labels = $calendar->labels(@date)) > 1))
    {
        $dow = shift(@labels);
        foreach $name (sort @labels)
        {
            $age = '';
            if ($name =~ s!\s*(\d+)\s*$!!)
            {
                $age = $date[0] - $1;
            }
            printf
            (
                "%+5d days :  %3.3s %2d-%3.3s-%d  (%2s)  %s\n",
                $delta,
                $dow,
                $date[2],
                Month_to_Text($date[1]),
                $date[0],
                $age,
                $name
            );
        }
    }
    @date = Add_Delta_Days(@date,1) if ($delta < $Days);
}

__END__