File Coverage

blib/lib/App/TimeClock/Daily/CsvPrinter.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 22 22 100.0


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