lib/Biblio/ILL/ISO/DateTime.pm

filter: Statementstmt 63.1% 24 / 38 Branchbran 28.5% 4 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 100% 3 / 3 totaltotal 55.8% 38 / 68 CC 10 SCAR 21.6
CC
10
Cov
53%
from_asn
20.0
set
12.0
new
5.3
CRAP 8.7
« lib/Biblio/ILL/ISO/DateDue.pm ↑ Summary lib/Biblio/ILL/ISO/ILLString.pm »
1 package Biblio::ILL::ISO::DateTime;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::DateTime
6  
7 =cut
8  
9 4 ▶use Biblio::ILL::ISO::ILLASNtype;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Biblio::ILL::ISO::ISODate;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Biblio::ILL::ISO::ISOTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 VERSION
16  
17 Version 0.01
18  
19 =cut
20  
21 4 our $VERSION = '0.01';
22 #---------------------------------------------------------------------------
23 # Mods
24 # 0.01 - 2003.07.15 - original version
25 #---------------------------------------------------------------------------
26  
27 =head1 DESCRIPTION
28  
29 Biblio::ILL::ISO::DateTime is a derivation of Biblio::ILL::ISO::ILLASNtype.
30  
31 =head1 USES
32  
33 Biblio::ILL::ISO::ISODate
34 Biblio::ILL::ISO::ISOTime
35  
36 =head1 USED IN
37  
38 Biblio::ILL::ISO::ServiceDateTime
39  
40 =cut
41  
42 4 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 =head1 FROM THE ASN DEFINITION
45
46 Date-Time ::= EXPLICIT SEQUENCE {
47 date [0] IMPLICIT ISO-Date,
48 time [1] IMPLICIT ISO-Time OPTIONAL
49 }
50  
51 =cut
52  
53 =head1 METHODS
54  
55 =cut
56  
57  
58 #---------------------------------------------------------------
59 #
60 #---------------------------------------------------------------
61 =head1
62  
63 =head2 new( $date [,$time] )
64  
65 Creates a new DateTime object.
66 Expects a date string (YYYYMMDD), and
67 (optionally) a time string (MMHHSS).
68  
69 =cut
70 43 ▶sub new {
Subroutine new: called CC=5 SCAR=16.6
Pod documented
71 43 my $class = shift;
72 43 my $self = {};
73  
74 43 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 43 0 43
75 43 my ($date, $time) = @_;
76  
77 43 ▶ croak "missing date" unless ($date);
Branch: 1 branch
BranchTrueFalseTotal
unless $date 0 43 43
78
79 43 $self->{"date"} = new Biblio::ILL::ISO::ISODate($date);
80 43 ▶ $self->{"time"} = new Biblio::ILL::ISO::ISOTime($time) if ($time);
Branch: 1 branch
BranchTrueFalseTotal
if $time 42 1 43
81 }
82  
83 43 ▶ bless($self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0430
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
84 43 return ($self);
85 }
86  
87  
88 #---------------------------------------------------------------
89 #
90 #---------------------------------------------------------------
91 =head1
92  
93 =head2 set( $date [,$time] )
94  
95 Sets the object's date (a date string (YYYYMMDD)), and
96 (optionally) time (a time string (MMHHSS)).
97  
98 =cut
99 0 ▶sub set {
Subroutine set: not called CC=3 SCAR=24.8
Pod documented
100 0 my $self = shift;
101 0 my ($date, $time) = @_;
102
103 0 ▶ croak "missing date" unless ($date);
Branch: 1 branch
BranchTrueFalseTotal
unless $date 0 0 0
104
105 0 $self->{"date"} = new Biblio::ILL::ISO::ISODate($date);
106 0 ▶ $self->{"time"} = new Biblio::ILL::ISO::ISOTime($time) if ($time);
Branch: 1 branch
BranchTrueFalseTotal
if $time 0 0 0
107  
108 0 return;
109 }
110  
111 #---------------------------------------------------------------
112 #
113 #---------------------------------------------------------------
114 =head1
115  
116 =head2 from_asn($href)
117  
118 Given a properly formatted hash, builds the object.
119  
120 =cut
121 0 ▶sub from_asn {
Subroutine from_asn: not called CC=4 SCAR=30.0
Pod documented
122 0 my $self = shift;
123 0 my $href = shift;
124  
125 0 foreach my $k (keys %$href) {
126 #print ref($self) . "...$k\n";
127  
128 0 ▶ if ($k =~ /^date$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ /^date$/) { } 0 0 0
elsif ($k =~ /^time$/) { } 0 0 0
129 0 $self->{$k} = new Biblio::ILL::ISO::ISODate($href->{$k});
130  
131 } elsif ($k =~ /^time$/) {
132 0 $self->{$k} = new Biblio::ILL::ISO::ISOTime($href->{$k});
133  
134 } else {
135 0 croak "invalid " . ref($self) . " element: [$k]";
136 }
137  
138 }
139 0 return $self;
140 }
141  
142 =head1 SEE ALSO
143  
144 See the README for system design notes.
145 See the parent class(es) for other available methods.
146  
147 For more information on Interlibrary Loan standards (ISO 10160/10161),
148 a good place to start is:
149  
150 http://www.nlc-bnc.ca/iso/ill/main.htm
151  
152 =cut
153  
154 =head1 AUTHOR
155  
156 David Christensen, <DChristensenSPAMLESS@westman.wave.ca>
157  
158 =cut
159  
160  
161 =head1 COPYRIGHT AND LICENSE
162  
163 Copyright 2003 by David Christensen
164  
165 This library is free software; you can redistribute it and/or modify it
166 under the same terms as Perl itself.
167  
168 =cut
169  
170 4 1;
« lib/Biblio/ILL/ISO/DateDue.pm ↑ Summary lib/Biblio/ILL/ISO/ILLString.pm »