File Coverage

blib/lib/App/Chart/Timebase/Days.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             # Copyright 2007, 2008, 2009 Kevin Ryde
2              
3             # This file is part of Chart.
4             #
5             # Chart is free software; you can redistribute it and/or modify it under the
6             # terms of the GNU General Public License as published by the Free Software
7             # Foundation; either version 3, or (at your option) any later version.
8             #
9             # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10             # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11             # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12             # details.
13             #
14             # You should have received a copy of the GNU General Public License along
15             # with Chart. If not, see <http://www.gnu.org/licenses/>.
16              
17              
18             package App::Chart::Timebase::Days;
19 1     1   331 use strict;
  1         2  
  1         24  
20 1     1   4 use warnings;
  1         2  
  1         24  
21 1     1   295 use Locale::TextDomain ('App-Chart');
  1         25600  
  1         11  
22              
23 1     1   9197 use App::Chart;
  0            
  0            
24             use base 'App::Chart::Timebase';
25              
26             sub new_from_ymd {
27             my ($class, $year, $month, $day) = @_;
28             return $class->SUPER::new
29             (base => App::Chart::ymd_to_tdate_floor ($year, $month, $day));
30             }
31              
32             sub to_ymd {
33             my ($self, $t) = @_;
34             return App::Chart::tdate_to_ymd ($t + $self->{'base'});
35             }
36              
37             sub from_ymd_floor {
38             my ($self, $year, $month, $day) = @_;
39             return App::Chart::ymd_to_tdate_floor ($year, $month, $day)
40             - $self->{'base'};
41             }
42              
43             sub from_ymd_ceil {
44             my ($self, $year, $month, $day) = @_;
45             return App::Chart::ymd_to_tdate_ceil ($year, $month, $day)
46             - $self->{'base'};
47             }
48              
49             sub adjective { return __('Daily'); }
50              
51             1;