EMIUCP/DDT.pm

filter: Statementstmt 100% 19 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 100% 27 / 27 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« EMIUCP.pm ↑ Summary EMIUCP/DSCTS.pm »
1 package DateTime::Format::EMIUCP::DDT;
2  
3 =head1 NAME
4  
5 DateTime::Format::EMIUCP::DDT - Parse DDT field for EMI-UCP protocol
6  
7 =head1 SYNOPSIS
8  
9 use DateTime::Format::EMIUCP::DDT;
10  
11 my $dt = DateTime::Format::EMIUCP::DDT->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::DDT->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 DDT is a string of 10 numeric characters which represents deferred delivery
25 time in ddMMyyHHmm format.
26  
27 See EMI-UCP Interface 5.2 Specification for further explanations.
28  
29 =cut
30  
31 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 3 our $VERSION = '0.0300';
37  
38 3 ▶use DateTime::Format::EMIUCP;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 3 ▶use DateTime::Format::Builder (
Subroutine BEGIN: called CC=1 SCAR=0.0
56 3 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 );
66  
67  
68 3 ▶BEGIN { *_fix_year = \&DateTime::Format::EMIUCP::_fix_year; }
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 ▶sub format_datetime {
Subroutine format_datetime: called CC=1 SCAR=0.0
Pod documented
81 1 my ($self, $dt) = @_;
82 1 return sprintf '%02d%02d%02d%02d%02d',
83 $dt->day, $dt->month, $dt->year % 100,
84 $dt->hour, $dt->minute;
85 };
86  
87  
88 3 1;
89  
90 __END__
« EMIUCP.pm ↑ Summary EMIUCP/DSCTS.pm »