blib/lib/oEdtk/DateField.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 18 CC 1 SCAR 6.9
CC
1
Cov
0%
process
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package oEdtk::DateField;
2  
3 use strict;
4 use warnings;
5  
6 use base 'oEdtk::Field';
7 our $VERSION = 2.1126;
8  
9 sub process {
10 my ( $self, $data ) = @_;
11  
12 $data =~ s/^(\d{4})(\d{2})(\d{2}).*$/$3\/$2\/$1/;
13 return $data;
14 }
15  
16 1;
17  
18 =head1 NAME
19  
20 oEdtk::DateField - date field: YYYYMMDD to DD/MM/YYYY
21  
22 =head1 SYNOPSIS
23  
24 use oEdtk::DateField;
25  
26 my $field = oEdtk::DateField->new('DATNAI', 8);
27 print $field->process('19700131'), "\n"; # '31/01/1970'
28  
29 =head1 DESCRIPTION
30  
31 An C<oEdtk::Field> subclass that rewrites a coded date C<YYYYMMDD> into the
32 display form C<DD/MM/YYYY>. Anything after the eight leading digits is dropped.
33  
34 =head1 METHODS
35  
36 =head2 process
37  
38 my $value = $field->process($data);
39  
40 Rewrite the leading eight digits of C<$data> as C<DD/MM/YYYY>.
41  
42 =head1 AUTHOR
43  
44 The oEdtk team.
45  
46 =cut