File Coverage

blib/lib/Biblio/ILL/ISO/DateTime.pm
Criterion Covered Total %
statement 22 36 61.1
branch 4 14 28.5
condition 1 3 33.3
subroutine 6 8 75.0
pod 3 3 100.0
total 36 64 56.2


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::DateTime;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::DateTime
6              
7             =cut
8              
9 4     4   589 use Biblio::ILL::ISO::ILLASNtype;
  4         7  
  4         122  
10 4     4   4581 use Biblio::ILL::ISO::ISODate;
  4         11  
  4         113  
11 4     4   2451 use Biblio::ILL::ISO::ISOTime;
  4         13  
  4         616  
12              
13 4     4   38 use Carp;
  4         9  
  4         360  
14              
15             =head1 VERSION
16              
17             Version 0.01
18              
19             =cut
20              
21             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     4   1921 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
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             sub new {
71 43     43 1 178 my $class = shift;
72 43         64 my $self = {};
73              
74 43 50       103 if (@_) {
75 43         61 my ($date, $time) = @_;
76              
77 43 50       88 croak "missing date" unless ($date);
78            
79 43         131 $self->{"date"} = new Biblio::ILL::ISO::ISODate($date);
80 43 100       180 $self->{"time"} = new Biblio::ILL::ISO::ISOTime($time) if ($time);
81             }
82              
83 43   33     179 bless($self, ref($class) || $class);
84 43         199 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             sub set {
100 0     0 1   my $self = shift;
101 0           my ($date, $time) = @_;
102            
103 0 0         croak "missing date" unless ($date);
104            
105 0           $self->{"date"} = new Biblio::ILL::ISO::ISODate($date);
106 0 0         $self->{"time"} = new Biblio::ILL::ISO::ISOTime($time) if ($time);
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             sub from_asn {
122 0     0 1   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 0         if ($k =~ /^date$/) {
    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,
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             1;