CalendarV3/Date.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 46 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Net::Google::CalendarV3::Date;
2 $Net::Google::CalendarV3::Date::VERSION = '0.16';
3 use Moose;
4 use Kavorka;
5 use DateTime::Format::ISO8601;
6 with 'Net::Google::CalendarV3::ToJson';
7 use Net::Google::CalendarV3::Types qw( CBool DateTime );
8 has $_, is => 'rw', clearer => "clear_$_" for qw( date dateTime timeZone );
9  
10 method set (DateTime $dt, CBool $is_all_day) {
11 if ($is_all_day) {
12 $self->date($dt->ymd);
13 $self->clear_dateTime;
14 $self->clear_timeZone;
15 } else {
16 $self->dateTime($dt->iso8601);
17 $self->timeZone($dt->time_zone->name) if $dt->time_zone && !$dt->time_zone->is_floating;
18 $self->clear_date;
19 }
20 }
21  
22 method get () {
23 if ($self->date) {
24 return ( DateTime::Format::ISO8601->parse_datetime($self->date), 1 );
25 } else {
26 my $dt = DateTime::Format::ISO8601->parse_datetime($self->dateTime);
27 eval { $dt->set_time_zone($self->timeZone) if $self->timeZone }; # ignore unknown time zones
28 return ( $dt, 0 );
29 }
30 }
31  
32 1;
33