File Coverage

blib/lib/Calendar/Plugin/Renderer/Util.pm
Criterion Covered Total %
statement 14 39 35.9
branch 0 6 0.0
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 19 54 35.1


line stmt bran cond sub pod time code
1             package Calendar::Plugin::Renderer::Util;
2              
3             $Calendar::Plugin::Renderer::Util::VERSION = '0.11';
4             $Calendar::Plugin::Renderer::Util::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             Calendar::Plugin::Renderer::Util - Helper package for Calendar::Plugin::Renderer.
9              
10             =head1 VERSION
11              
12             Version 0.11
13              
14             =cut
15              
16 3     3   11 use vars qw(@ISA @EXPORT);
  3         6  
  3         244  
17             require Exporter;
18             @ISA = qw(Exporter);
19             @EXPORT = qw(round_number get_max_week_rows);
20              
21 3     3   51 use 5.006;
  3         8  
22 3     3   10 use strict; use warnings;
  3     3   4  
  3         64  
  3         10  
  3         4  
  3         76  
23 3     3   11 use Data::Dumper;
  3         4  
  3         717  
24              
25             =head1 DESCRIPTION
26              
27             B.
28              
29             =head2 METHODS
30              
31             =head1 round_number($number, $digits)
32              
33             Round the given C<$number> by C<$digits>. By default round it by 4 digits.
34              
35             =cut
36              
37             sub round_number {
38 0     0 0   my ($number, $digits) = @_;
39              
40 0 0         $digits = 4 unless defined $digits;
41 0           my $format = sprintf("%02d", $digits);
42 0           $format = '%.' . $format . 'f';
43              
44 0           return sprintf($format, $number);
45             }
46              
47             sub get_max_week_rows {
48 0     0 0   my ($start_index, $max_days, $max_week_row) = @_;
49              
50 0           my $rows = 1;
51 0           my $i = 1;
52 0           while ($i < $start_index) {
53 0           $i++;
54             }
55              
56 0           my $d = 1;
57 0           while ($i <= 7) {
58 0           $d++;
59 0           $i++;
60             }
61              
62 0           $rows++;
63 0           my $k = 1;
64 0           while ($d <= $max_days) {
65 0 0         if ($k == 7) {
66 0           $rows++;
67 0           $k = 1;
68             }
69             else {
70 0           $k++;
71             }
72 0           $d++;
73             }
74              
75 0 0         if ($rows < $max_week_row) {
76 0           return $max_week_row;
77             }
78             else {
79 0           return $rows;
80             }
81             }
82              
83             =head1 AUTHOR
84              
85             Mohammad S Anwar, C<< >>
86              
87             =head1 REPOSITORY
88              
89             L
90              
91             =head1 BUGS
92              
93             Please report any bugs / feature requests to C,
94             or through the web interface at L.
95             I will be notified, and then you'll automatically be notified of progress on your
96             bug as I make changes.
97              
98             =head1 SUPPORT
99              
100             You can find documentation for this module with the perldoc command.
101              
102             perldoc Calendar::Plugin::Renderer::Util
103              
104             You can also look for information at:
105              
106             =over 4
107              
108             =item * RT: CPAN's request tracker
109              
110             L
111              
112             =item * AnnoCPAN: Annotated CPAN documentation
113              
114             L
115              
116             =item * CPAN Ratings
117              
118             L
119              
120             =item * Search CPAN
121              
122             L
123              
124             =back
125              
126             =head1 LICENSE AND COPYRIGHT
127              
128             Copyright (C) 2015 - 2016 Mohammad S Anwar.
129              
130             This program is free software; you can redistribute it and / or modify it under
131             the terms of the the Artistic License (2.0). You may obtain a copy of the full
132             license at:
133              
134             L
135              
136             Any use, modification, and distribution of the Standard or Modified Versions is
137             governed by this Artistic License.By using, modifying or distributing the Package,
138             you accept this license. Do not use, modify, or distribute the Package, if you do
139             not accept this license.
140              
141             If your Modified Version has been derived from a Modified Version made by someone
142             other than you,you are nevertheless required to ensure that your Modified Version
143             complies with the requirements of this license.
144              
145             This license does not grant you the right to use any trademark, service mark,
146             tradename, or logo of the Copyright Holder.
147              
148             This license includes the non-exclusive, worldwide, free-of-charge patent license
149             to make, have made, use, offer to sell, sell, import and otherwise transfer the
150             Package with respect to any patent claims licensable by the Copyright Holder that
151             are necessarily infringed by the Package. If you institute patent litigation
152             (including a cross-claim or counterclaim) against any party alleging that the
153             Package constitutes direct or contributory patent infringement,then this Artistic
154             License to you shall terminate on the date that such litigation is filed.
155              
156             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
157             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
158             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
159             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
160             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
161             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
162             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
163              
164             =cut
165              
166             1; # End of Calendar::Plugin::Renderer::Util