-
Notifications
You must be signed in to change notification settings - Fork 1
/
redmine_maker.pl
executable file
·46 lines (40 loc) · 1.29 KB
/
redmine_maker.pl
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
#!/usr/bin/env perl
use DateTime;
use DateTime::TimeZone;
use DateTime::Format::Strptime;
use Date::Calc qw( Date_to_Days );
my $csvfile = "./WorkLog2015/Work\ Log-Daily\ Breakdown.csv";
my $htmlout = "WorkLog2015.txt";
my $dt;
open INPUT, $csvfile or die "Can't open csv file!";
open HTMOUT, ">./$htmlout" or die "Can't open html out!";
print HTMOUT "|_.Date|_.Morning|_.Afternoon|_.Notes|\n";
# print HTMOUT "|_.Date|_.Morning|_.Afternoon|_.Notes|_.Planned Focus|\n";
while(<INPUT>) {
chomp;
s/\r/|/g;
# s/,/|/g;
my @entries = split(',', $_);
my $parser = DateTime::Format::Strptime->new(
pattern => '%m/%d/%Y',
on_error => 'undef',
);
$dt = $parser->parse_datetime($entries[0]) or $dt="wookie";
if ($dt ne "wookie") {
my $now = DateTime->now();
my $then = DateTime->now()->subtract( days => 7 );
$lower = Date_to_Days($then->year(),$then->month(),$then->day());
$upper = Date_to_Days($now->year(),$now->month(),$now->day());
$date = Date_to_Days($dt->year(),$dt->month(),$dt->day());
if (($date >= $lower) && ($date <= $upper)) {
print HTMOUT "|";
print HTMOUT $parser->format_datetime($dt);
for ($i=1; $i<scalar @entries; $i++) {
print HTMOUT "|".$entries[$i]
}
print HTMOUT "\n";
}
}
}
close (INPUT);
close (HTMOUT);