File Coverage

blib/lib/DBIx/MoCo/Column/UTCDateTime.pm
Criterion Covered Total %
statement 22 22 100.0
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package DBIx::MoCo::Column::UTCDateTime;
2 1     1   20 use strict;
  1         3  
  1         44  
3 1     1   6 use warnings;
  1         2  
  1         31  
4 1     1   7 use DateTime;
  1         3  
  1         10  
5 1     1   24 use DateTime::Format::MySQL;
  1         2  
  1         11  
6              
7             sub UTCDateTime {
8 4     4 0 8 my $self = shift;
9 4 100       19 return if not $$self;
10 3 50       53 return if $$self =~ /0000/o;
11 3         31 my $dt = DateTime::Format::MySQL->parse_datetime($$self);
12 3         2555 $dt->set_time_zone('UTC');
13 3         1611 return $dt;
14             }
15              
16             sub UTCDateTime_as_string {
17 2     2 0 5 my $class = shift;
18 2 50       10 my $dt = shift or return;
19 2         96 $dt->set_time_zone('UTC');
20 2         380 return DateTime::Format::MySQL->format_datetime($dt);
21             }
22              
23             1;