-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage.pm
78 lines (69 loc) · 2.39 KB
/
Message.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package Biblio::3MSIP::Message;
use strict;
use warnings;
use Carp;
use Class::Accessor 'antlers';
use DateTime;
has message_text => ( is => 'ro', isa => 'Str' );
has message_identifier => ( is => 'rw', isa => 'Int' );
sub to_datetime {
# convert date/time string (ANSI X3.30, X3.43) into DateTime object
my $self = shift;
my $datetime_str = shift;
my $datetime = DateTime->new(
year => substr($datetime_str,0,4),
month => substr($datetime_str,4,2),
day => substr($datetime_str,6,2),
hour => substr($datetime_str,12,2),
minute => substr($datetime_str,14,2),
second => substr($datetime_str,16)
);
return $datetime;
}
sub to_datetime_str {
# convert DateTime object into date/time string (ANSI X3.30, X.3.43)
my ($self,$datetime) = @_;
my $datetime_str = $datetime->year . sprintf('%02d',$datetime->month) . sprintf('%02d',$datetime->day) . ' ' . sprintf('%02d',$datetime->hour) . sprintf('%02d',$datetime->minute) . sprintf('%02d',$datetime->second);
return $datetime_str;
}
sub fee_type_text {
# look up fee type text
my $self = shift;
my $fee_type_text;
if ($self->fee_type) {
my @fee_type = (undef,'other/unknown','administrative','damage','overdue','processing','rental','replacement','computer access charge','hold fee');
$fee_type_text = $fee_type[$self->fee_type]?$fee_type[$self->fee_type]:undef;
}
return $fee_type_text;
}
sub media_type_text {
# look up media type text
my $self = shift;
my $media_type_text;
if ($self->media_type) {
my @media_type = ('other','book','magazine','bound journal','audio tape','video tape','CD/CDROM','diskette','book with diskette','book with CD','book with audio tape');
$media_type_text = $media_type[$self->media_type]?$media_type[$self->media_type]:undef;
}
return $media_type_text;
}
sub hold_mode_text {
# look up hold mode text
my $self = shift;
my $hold_mode_text;
if ($self->hold_mode) {
my %hold_mode= ('+','add','-','delete','*','change');
$hold_mode_text = $hold_mode{$self->hold_mode}?$hold_mode{$self->hold_mode}:undef;
}
return $hold_mode_text;
}
sub hold_type {
# look up hold type text
my $self = shift;
my $hold_type_text;
if ($self->hold_type) {
my @hold_type = (undef,'other','any copy','specific copy','any copy at a single location');
$hold_type_text = $hold_type[$self->hold_type]?$hold_type[$self->hold_type]:undef;
}
return $hold_type_text;
}
1;