line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::EMIUCP::VP; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DateTime::Format::EMIUCP::VP - Parse VP field for EMI-UCP protocol |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use DateTime::Format::EMIUCP::VP; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $dt = DateTime::Format::EMIUCP::VP->parse_datetime('0302120655'); |
12
|
|
|
|
|
|
|
print $dt->ymd; # 2012-02-03 |
13
|
|
|
|
|
|
|
print $dt->hms; # 06:55:00 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$dt->set_formatter(DateTime::Format::EMIUCP::VP->new); |
16
|
|
|
|
|
|
|
print $dt; # 0302120655 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This format is a part of EMI-UCP protocol message. EMI-UCP protocol is |
21
|
|
|
|
|
|
|
primarily used to connect to short message service centers (SMSCs) for mobile |
22
|
|
|
|
|
|
|
telephones. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
VP is a string of 10 numeric characters which represents validity period time |
25
|
|
|
|
|
|
|
in ddMMyyHHmm format. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
See EMI-UCP Interface 5.2 Specification for further explanations. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
3
|
|
208476
|
use 5.006; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
145
|
|
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
144
|
|
34
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
151
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $VERSION = '0.0300'; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
3
|
|
1803
|
use DateTime::Format::EMIUCP; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
351
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item DateTime I<$dt> = $fmt->parse_datetime(Str I<$scts>) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Given a string in the pattern specified in the constructor, this method will |
47
|
|
|
|
|
|
|
return a new DateTime object. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Year number below 70 means the date before year 2000. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
If given a string that doesn't match the pattern, the formatter will croak. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use DateTime::Format::Builder ( |
56
|
3
|
|
|
|
|
43
|
parsers => { |
57
|
|
|
|
|
|
|
parse_datetime => [ |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
params => [qw( day month year hour minute )], |
60
|
|
|
|
|
|
|
regex => qr/^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, |
61
|
|
|
|
|
|
|
postprocess => \&_fix_year, |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
] |
64
|
|
|
|
|
|
|
} |
65
|
3
|
|
|
3
|
|
30
|
); |
|
3
|
|
|
|
|
47
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
3
|
|
2688
|
BEGIN { *_fix_year = \&DateTime::Format::EMIUCP::_fix_year; } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item Str I<$scts> = $fmt->format_datetime(DateTime I<$dt>) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Given a DateTime object, this methods returns a string formatted in the |
74
|
|
|
|
|
|
|
object's format. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub format_datetime { |
81
|
1
|
|
|
1
|
1
|
2650
|
my ($self, $dt) = @_; |
82
|
1
|
|
|
|
|
8
|
return sprintf '%02d%02d%02d%02d%02d', |
83
|
|
|
|
|
|
|
$dt->day, $dt->month, $dt->year % 100, |
84
|
|
|
|
|
|
|
$dt->hour, $dt->minute; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |