Thread Date::Calc: alle Freitage (3 answers)
Opened by Froschpopo at 2008-03-14 16:41

renee
 2008-03-14 16:59
#107066 #107066
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl

use strict;
use warnings;
use Date::Calc qw(
    Add_Delta_Days
    Monday_of_Week
    Week_of_Year
);
use Data::Dumper;

my @start = (1,1,2007);
my @end   = (14,4,2009);

my ($year,$month,$day) = Add_Delta_Days( Monday_of_Week( Week_of_Year( reverse @start ) ), 4 );
    print Dumper $year,$month,$day;

my @fridays;
while( sprintf("%04d%02d%02d",$year,$month,$day) < sprintf("%04d%02d%02d",reverse @end) ){
    push @fridays, sprintf "%02d.%02d.%04d", $day,$month,$year;
    ($year,$month,$day) = Add_Delta_Days( $year,$month,$day, 7 );
}

print $_,"\n" for @fridays;
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Date::Calc: alle Freitage