File: age_in_days_us.pl

package info (click to toggle)
libdate-pcalc-perl 6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 1,856 kB
  • ctags: 619
  • sloc: perl: 16,706; ansic: 3,083; sh: 14; makefile: 4
file content (147 lines) | stat: -rwxr-xr-x 4,703 bytes parent folder | download | duplicates (3)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/perl -w

###############################################################################
##                                                                           ##
##    Copyright (c) 1998 - 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);

$please_enter_birthday[0] = "Please enter the date of your birthday (month-day-year)";
$please_enter_birthday[1] = "S.v.p. saisissez la date de votre anniversaire (mois-jour-anne)";
$please_enter_birthday[2] = "Bitte geben Sie das Datum Ihres Geburtstages ein (Monat-Tag-Jahr)";
$please_enter_birthday[3] = "Por favor ingrese la fecha de su cumpleaos (mes-da-ao)";
$please_enter_birthday[4] = "Por favor entre a data do seu aniversrio (ms-dia-ano)";
$please_enter_birthday[5] = "A.u.b. geef het datum van U verjaardag in (maand-daag-jaar)";

$please_enter_today[0] = "Please enter today's date (month-day-year)";
$please_enter_today[1] = "S.v.p. saisissez la date d'aujourd'hui (mois-jour-anne)";
$please_enter_today[2] = "Bitte geben Sie das heutige Datum ein (Monat-Tag-Jahr)";
$please_enter_today[3] = "Por favor ingrese la fecha de hoy (mes-da-ao)";
$please_enter_today[4] = "Por favor entre a data de hoje (ms-dia-ano)";
$please_enter_today[5] = "A.u.b. geef het datum van vandaag in (maand-daag-jaar)";

$your_birthday_is[0] = "Your birthday is";
$your_birthday_is[1] = "Votre anniversaire est";
$your_birthday_is[2] = "Ihr Geburtstag ist";
$your_birthday_is[3] = "Su cumpleaos es";
$your_birthday_is[4] = "Seu aniversrio ";
$your_birthday_is[5] = "U verjaardag is";

$today_is[0] = "Today is";
$today_is[1] = "Aujourd'hui est";
$today_is[2] = "Heute ist";
$today_is[3] = "Hoy es";
$today_is[4] = "Hoje ";
$today_is[5] = "Vandaag is";

$correct[0] = "Is that correct? (Yes/No)";
$correct[1] = "Est-ce exact? (Oui/Non)";
$correct[2] = "Ist das richtig? (Ja/Nein)";
$correct[3] = "Es esto correcto? (Si/No)";
$correct[4] = "Est certo? (Sim/No)";
$correct[5] = "Is dat juist? (Ja/Nee)";

$yes[0] = "y";
$yes[1] = "o";
$yes[2] = "j";
$yes[3] = "s";
$yes[4] = "s";
$yes[5] = "j";

$you_are[0] = "You are %s days old";
$you_are[1] = "Vous tes g de %s jours";
$you_are[2] = "Sie sind %s Tage alt";
$you_are[3] = "Su edad es %s das";
$you_are[4] = "Voc tem uma idade de %s dias";
$you_are[5] = "U bent %s dagen oud";

for ( $i = 1; $i <= 6; $i++ ) { $language[$i-1] = Language_to_Text($i); }

$languages = join(", ",@language);

print "\n";

$ok = 0;
while (! $ok)
{
    print "Please choose a language among $languages: ";
    chomp($lang = <STDIN>);
    print "\n";
    if (($lang = Decode_Language($lang)) && ($lang < 7))
    {
        $string0 = Language_to_Text($lang);
        print "Your chosen language is: $string0\n";
        print "\n";
        print "Is that correct? (Yes/No) ";
        $response = <STDIN>;
        print "\n";
        $ok = ($response =~ /^Y/i);
    }
}

Language($lang--);

$ok = 0;
while (! $ok)
{
    print "$please_enter_birthday[$lang]: ";
    $date = <STDIN>;
    print "\n";
    if (($yy1,$mm1,$dd1) = Decode_Date_US($date))
    {
        $string1 = Date_to_Text_Long($yy1,$mm1,$dd1);
        print "$your_birthday_is[$lang]: $string1\n";
        print "\n";
        print "$correct[$lang] ";
        $response = <STDIN>;
        print "\n";
        $ok = ($response =~ /^$yes[$lang]/io);
    }
}

eval { ($yy2,$mm2,$dd2) = Today(); };

if ($@)
{
    $ok = 0;
    while (! $ok)
    {
        print "$please_enter_today[$lang]: ";
        $date = <STDIN>;
        print "\n";
        if (($yy2,$mm2,$dd2) = Decode_Date_US($date))
        {
            $string2 = Date_to_Text_Long($yy2,$mm2,$dd2);
            print "$today_is[$lang]: $string2\n";
            print "\n";
            print "$correct[$lang] ";
            $response = <STDIN>;
            print "\n";
            $ok = ($response =~ /^$yes[$lang]/io);
        }
    }
}
else { $string2 = Date_to_Text_Long($yy2,$mm2,$dd2); }

print "$your_birthday_is[$lang]: $string1\n";
print "\n";

print "$today_is[$lang]: $string2\n";
print "\n";

$days = Delta_Days($yy1,$mm1,$dd1,$yy2,$mm2,$dd2);
printf("$you_are[$lang].\n", $days);
print "\n";

__END__