File: cal.pl

package info (click to toggle)
libdate-pcalc-perl 1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 428 kB
  • ctags: 80
  • sloc: perl: 4,738; makefile: 42; sh: 18
file content (66 lines) | stat: -rwxr-xr-x 1,529 bytes parent folder | download | duplicates (2)
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
#!perl -w

#############################################################################
#                                                                           #
#    Copyright (c) 1999 by J. David Eisenberg                               #
#    All rights reserved.                                                   #
#                                                                           #
#    This program is free software; you can redistribute it                 #
#    andor modify it under the same terms as Perl.                          #
#                                                                           #
#############################################################################

use strict;
no strict "vars";

use Date::Pcalc qw(:all);

if ((scalar @ARGV != 2) && (scalar @ARGV != 3))
{
    die("Usage: $0 <month> <year> <language>\n");
}

$month_arg = $ARGV[0];
$year = $ARGV[1];

if (scalar @ARGV == 3)
{
    $lingo = $ARGV[2];

    if (($lang = Decode_Language ($lingo)) == 0 )
    {
        $lang = $lingo;
    }
}
else
{
    $lang = Language();
}

if ( ($lang < 1) || ($lang > Languages()))
{
    die("$0: the chosen language ($lingo) is not available!\n");
}
else
{
    Language( $lang );

}

if ( ($month = Decode_Month( $month_arg )) == 0)
{
    $month = $month_arg;
}

if (($month < 1) || ($month > 12))
{
    die("$0: the given month ($month_arg) is out of range!\n");
}

if ($year < 1)
{
    die("$0: the given year ($year) is out of range!\n");
}

print Calendar( $year, $month );