File Coverage

blib/lib/Date/Simple/Fmt.pm
Criterion Covered Total %
statement 14 17 82.3
branch n/a
condition n/a
subroutine 5 8 62.5
pod 4 4 100.0
total 23 29 79.3


line stmt bran cond sub pod time code
1             package Date::Simple::Fmt;
2 3     3   18 use Date::Simple 3;
  3         59  
  3         248  
3 3     3   17 use base qw/Date::Simple/;
  3         24  
  3         416  
4 3     3   20 use overload '""' => '_format';
  3         5  
  3         21  
5              
6             *EXPORT = *Date::Simple::EXPORT;
7             *EXPORT_OK = *Date::Simple::EXPORT_OK;
8             *EXPORT_TAGS = *Date::Simple::EXPORT_TAGS;
9              
10 0     0 1 0 sub d8 { shift->_d8(@_) }
11 0     0 1 0 sub today { shift->_today(@_) }
12 0     0 1 0 sub ymd { shift->_ymd(@_) }
13              
14             sub new {
15 2     2 1 14 my ( $class, $fmt, @args ) = @_;
16 2         13 my $self = $class->SUPER::new(@args);
17 2         13 $self->default_format($fmt);
18 2         5 $self;
19             }
20              
21 2     2   2463 sub _format { shift->format() }
22              
23             1;
24              
25             =head1 NAME
26              
27             Date::Simple::Fmt - Sub class of Date::Simple with per object level formatting for
28             overloaded stringification.
29              
30             =head1 SYNOPSIS
31              
32             use Date::Simple::Fmt;
33              
34             =head1 DESCRIPTION
35              
36             This module changes the default stringification behaviour of Date::Simple objects to
37             use the format() method instead. It also changes the behaviour of the constructor.
38              
39             =item Date::Simple::Fmt->new (FMT, [ARG, ...])
40              
41             =item date_fmt (FMT, [ARG, ...])
42              
43             Follows the same rules as for the equivelent method (new) and subroutine (date) in
44             Date::Simple except that the first argument is expected to be the default format for
45             the newly created object. It is this format that will be used when using overloaded
46             stringification or when not providing a format argument to the format() method.
47              
48             =head1 SEE ALSO
49              
50             L for full documentation.
51              
52             =cut