Thread kalender (13 answers)
Opened by popcorn5 at 2003-10-02 01:33

format_c
 2003-10-02 02:19
#59775 #59775
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
Um Herauszufinden, brauchst du aber kein Calendar Modul. Das geht auch mit Time::Local:
Code: (dl )
1
2
3
4
5
6
7
8
use strict;
use warnings;
use Time::Local;
my $month = 2;
my $diff = timelocal(0,0,0,1,$month,2003-1900)-timelocal(0,0,0,1,$month-1,2003-1900);
print "Tage: ",(localtime($diff))[7];

28


Und ein Datum prüfen pob es das gibt:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use strict;
use warnings;
use Time::Local;
my $month = 2;
my $day = 29;
my $year = 2003;
eval {timelocal(0,0,0,$day,$month-1,$year-1900)};

if ($@) {
print "Datum ungültig.";
}
else {
print "Datum gültig.";
}

Datum ungültig.


Gruß Alex

View full thread kalender