line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::EMIUCP; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DateTime::Format::EMIUCP - Parse time formats for EMI-UCP protocol |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use DateTime::Format::EMIUCP; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $scts = DateTime::Format::EMIUCP->parse_datetime('030212065530'); |
12
|
|
|
|
|
|
|
print $scts->ymd; # 2012-02-03 |
13
|
|
|
|
|
|
|
print $scts->hms; # 06:55:30 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $vp = DateTime::Format::EMIUCP->parse_datetime('0302120655'); |
16
|
|
|
|
|
|
|
print $vp->ymd; # 2012-02-03 |
17
|
|
|
|
|
|
|
print $vp->hms; # 06:55:00 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
These formats are part of EMI-UCP protocol message. EMI-UCP protocol is |
22
|
|
|
|
|
|
|
primarily used to connect to short message service centers (SMSCs) for mobile |
23
|
|
|
|
|
|
|
telephones. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
SCTS is a string of 12 numeric characters which represents Service Center |
26
|
|
|
|
|
|
|
time-stamp in ddMMyyHHmmss format. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
DSCTS is a string of 12 numeric characters which represents Delivery |
29
|
|
|
|
|
|
|
time-stamp in ddMMyyHHmmss format. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
DDT is a string of 10 numeric characters which represents deferred delivery |
32
|
|
|
|
|
|
|
time in ddMMyyHHmm format. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
VP is a string of 10 numeric characters which represents validity period time |
35
|
|
|
|
|
|
|
in ddMMyyHHmm format. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
See EMI-UCP Interface 5.2 Specification for further explanations. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=for readme stop |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
14
|
|
|
14
|
|
108430
|
use 5.006; |
|
14
|
|
|
|
|
53
|
|
|
14
|
|
|
|
|
557
|
|
44
|
|
|
|
|
|
|
|
45
|
14
|
|
|
14
|
|
79
|
use strict; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
444
|
|
46
|
14
|
|
|
14
|
|
80
|
use warnings; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
2661
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our $VERSION = '0.0300'; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item DateTime I<$dt> = $fmt->parse_datetime(Str I<$scts>) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Given a string in the pattern specified in the constructor, this method will |
57
|
|
|
|
|
|
|
return a new DateTime object. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Year number below 70 means the date before year 2000. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
If given a string that doesn't match the pattern, the formatter will croak. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use DateTime::Format::Builder ( |
68
|
14
|
|
|
|
|
445
|
parsers => { |
69
|
|
|
|
|
|
|
parse_datetime => [ |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
params => [qw( day month year hour minute second )], |
72
|
|
|
|
|
|
|
regex => qr/^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, |
73
|
|
|
|
|
|
|
postprocess => \&_fix_year, |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
params => [qw( day month year hour minute )], |
77
|
|
|
|
|
|
|
regex => qr/^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/, |
78
|
|
|
|
|
|
|
postprocess => \&_fix_year, |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
] |
81
|
|
|
|
|
|
|
} |
82
|
14
|
|
|
14
|
|
20415
|
); |
|
14
|
|
|
|
|
5660318
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _fix_year { |
86
|
30
|
|
|
30
|
|
50479
|
my %args = @_; |
87
|
30
|
|
|
|
|
96
|
my ($date, $p) = @args{qw( input parsed )}; |
88
|
30
|
100
|
|
|
|
159
|
$p->{year} += $p->{year} > 69 ? 1900 : 2000; |
89
|
30
|
|
|
|
|
133
|
return 1; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |