File Coverage

blib/lib/App/TimeClock/Daily/CsvPrinter.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 3 3 100.0
total 14 14 100.0


line stmt bran cond sub pod time code
1             package App::TimeClock::Daily::CsvPrinter;
2              
3             our @ISA = qw(App::TimeClock::Daily::PrinterInterface);
4              
5 1     1   357 use POSIX qw(strftime);
  1         2  
  1         4  
6              
7             =head1 NAME
8              
9             App::TimeClock::Daily::CsvPrinter
10              
11             =head1 DESCRIPTION
12              
13             Implements the L. Will print total
14             for each day in a comma separated format.
15              
16             =head1 METHODS
17              
18             =over
19              
20             =cut
21              
22             =item print_header()
23              
24             There's no header when print CSV. This is an empty sub.
25              
26             =cut
27       2 1   sub print_header {};
28              
29             =item print_day()
30              
31             Prints totals for each day. Five fields are printed: week day, date,
32             start time, end time and total hours worked. Example:
33              
34             "Mon","2012/03/12","08:21:16","16:05:31",7.732222
35              
36             =cut
37             sub print_day {
38 3     3 1 8 my ($self, $date, $start, $end, $work, %projects) = (@_);
39 3         9 my ($year, $mon, $mday) = split(/\//, $date);
40 3         67 my $wday = substr(strftime("%a", 0, 0, 0, $mday, $mon-1, $year-1900),0,3);
41              
42 3         37 $self->_print(sprintf('"%s","%s","%s","%s",%f' . "\n",$wday, $date, $start, $end, $work));
43             };
44              
45             =item print_footer()
46              
47             There's no footer when print CSV. This is an empty sub.
48              
49             =cut
50       2 1   sub print_footer {};
51             1;
52              
53             =back
54              
55             =for text
56             =encoding utf-8
57             =end
58              
59             =head1 AUTHOR
60              
61             Søren Lund, C<< >>
62              
63             =head1 SEE ALSO
64              
65             L
66              
67             =head1 COPYRIGHT
68              
69             Copyright (C) 2012-2015 Søren Lund
70              
71             This file is part of App::TimeClock.
72              
73             App::TimeClock is free software: you can redistribute it and/or modify
74             it under the terms of the GNU General Public License as published by
75             the Free Software Foundation, either version 3 of the License, or
76             (at your option) any later version.
77              
78             App::TimeClock is distributed in the hope that it will be useful,
79             but WITHOUT ANY WARRANTY; without even the implied warranty of
80             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81             GNU General Public License for more details.
82              
83             You should have received a copy of the GNU General Public License
84             along with App::TimeClock. If not, see .