File Coverage

blib/lib/App/JobLog/Time.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition 4 6 66.6
subroutine 8 8 100.0
pod 3 3 100.0
total 35 37 94.5


line stmt bran cond sub pod time code
1             package App::JobLog::Time;
2             $App::JobLog::Time::VERSION = '1.040';
3             # ABSTRACT: consolidates basic time functions into one location
4              
5              
6 6     6   3629 use Exporter 'import';
  6         11  
  6         285  
7             our @EXPORT_OK = qw(
8             now
9             today
10             tz
11             );
12              
13 6     6   31 use Modern::Perl;
  6         10  
  6         41  
14 6     6   2027 use DateTime;
  6         127109  
  6         63  
15 6     6   4210 use DateTime::TimeZone;
  6         119072  
  6         33  
16 6     6   846 use App::JobLog::Config qw(_tz);
  6         12  
  6         1172  
17              
18             # cached values
19             our ( $today, $now );
20              
21              
22             sub now {
23 98   66 98 1 464 $now //= DateTime->now( time_zone => tz() );
24 98         85441 return $now->clone;
25             }
26              
27              
28             sub today {
29 306   66 306 1 1116 $today //= now()->truncate( to => 'day' );
30 306         8709 return $today->clone;
31             }
32              
33              
34             sub tz {
35 25810     25810 1 230730 _tz;
36             }
37              
38             1;
39              
40             __END__