7 Einträge, 1 Seite |
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
use strict;
use Date::Calc qw(This_Year Week_of_Year);
my @month_max_days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
my $this_year = This_Year();
sub is_leapyear
{
my ($year) = @_;
if(!$year) { return "-1" }
if($year % 4 == 0) { $v = 1 }
if($year % 100 == 0) { $v = 0 }
if($year % 400 == 0) { $v = 1 }
return $v;
}
my $is_leapyear = is_leapyear($this_year);
my %weeks_of_year = ();
for my $month (0 .. scalar(@month_max_days) - 1)
{
my $week = 0;
my @dates = ();
my $date = "";
my $max_days = $month_max_days[$month];
$max_days += 1 if $month == 1 and $is_leapyear;
for my $day (0 .. $max_days-1)
{
($week, undef) = Week_of_Year($this_year, $month, $day);
unless(defines $weeks_of_year{$week})
{
$weeks_of_year{$week} = [];
}
$date = "$this_year.$month.$day";
push @{$weeks_of_year{$week}}, $date;
}
}
print join(", ", @{$weeks_of_year{47}});
1 2 3 4 5 6 7 8 9 10 11
use Date::Calc qw(Date_to_Days Add_Delta_Days Monday_of_Week); # den Montag der Kalenderwoche ermitteln und in Tage seit 01.01.0001 umrechnen my $monday = Date_to_Days Monday_of_Week 47, 2003; # die 4 Tage drauf, dann ist Freitag der Woche my $friday = $monday + 4; # und alles ausgeben for ($monday, $friday) { # Days_to_Date gibt es nicht, deswegen Add_Delta_Days # Add_Delta_Days gibt ($year, $month, $day) zurück, deswegen reverse printf "%02d.%02d.%04d", reverse Add_Delta_Days 1, 1, 1, $_-1; }
7 Einträge, 1 Seite |