Code/DateTime.pm

filter: Statementstmt 100% 22 / 22 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 96.6% 29 / 30 CC 3 SCAR 7.9
CC
3
Cov
96%
new_from_string
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Code/AtomParser.pm ↑ Summary Code/Role/Fetchable.pm »
1 package Net::Google::Code::DateTime;
2 9 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 extends 'DateTime';
4  
5 9 our %MONMAP = (
6 Jan => 1,
7 Feb => 2,
8 Mar => 3,
9 Apr => 4,
10 May => 5,
11 Jun => 6,
12 Jul => 7,
13 Aug => 8,
14 Sep => 9,
15 Oct => 10,
16 Nov => 11,
17 Dec => 12,
18 );
19  
20 54 ▶sub new_from_string {
Subroutine new_from_string: called CC=3 SCAR=11.0
Pod documented
21 54 my $class = shift;
22 54 my $base_date = shift;
23 54 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($base_date =~ /\w{3}\s+(\w+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\d{4})/) { } 10 44 54
elsif ($base_date =~ /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/) { } 44 0 44
24 $base_date =~ /\w{3}\s+(\w+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\d{4})/ )
25 {
26 # Tue Jan 6 19:17:39 2009
27 10 my $mon = $1;
28 10 my $dom = $2;
29 10 my $h = $3;
30 10 my $m = $4;
31 10 my $s = $5;
32 10 my $y = $6;
33 my $date = $class->new(
34 year => $y,
35 10 month => $MONMAP{$mon},
36 day => $dom,
37 hour => $h,
38 minute => $m,
39 second => $s,
40 time_zone => 'US/Pacific', # google's time zone
41 );
42 10 $date->set_time_zone( 'UTC' );
43 10 return $date;
44 }
45 elsif ( $base_date =~ /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/ )
46 {
47  
48 # 2009-06-01T13:00:10Z
49 44 return $class->new(
50 year => $1,
51 month => $2,
52 day => $3,
53 hour => $4,
54 minute => $5,
55 second => $6,
56 time_zone => 'UTC',
57 );
58 }
59 }
60  
61 9 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 9 1;
64  
65 __END__
« Code/AtomParser.pm ↑ Summary Code/Role/Fetchable.pm »