| 1 | package DateTime::Format::Strftimeq; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $DATE = '2019-11-19'; # DATE | |||||||||
| 4 | 2 | our $DIST = 'DateTime-Format-Strftimeq'; # DIST | |||||||||
| 5 | 2 | our $VERSION = '0.001'; # VERSION | |||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use DateTimeX::strftimeq; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 3 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||
| 14 | 3 | my ($class, %args) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 3 | my $self = {}; | |||||||||
| 17 | |||||||||||
| 18 | 3 | ▶ | if (defined(my $time_zone = delete $args{time_zone})) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | $self->{time_zone} = do { | |||||||||
| 20 | 1 | ▶ | if (ref $time_zone) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 0 | $time_zone; | |||||||||
| 22 | } else { | ||||||||||
| 23 | 1 | require DateTime::TimeZone; | |||||||||
| 24 | 1 | DateTime::TimeZone->new(name => $time_zone); | |||||||||
| 25 | } | ||||||||||
| 26 | }; | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 2 | $self->{format} = delete $args{format}; | |||||||||
| 30 | 2 | ▶ | defined $self->{format} or die "Please specify 'format'"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 1 | ▶ | if (keys %args) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | die "Unknown attribute(s): ".join(", ", sort keys %args); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | bless $self, $class; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 2 | ▶ | sub format_datetime { | ||||||||
|
Subroutine
format_datetime: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 40 | 2 | my ($self, $dt) = @_; | |||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | if ($self->{time_zone}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $dt = $dt->clone->set_time_zone($self->{time_zone}); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 2 | strftimeq($self->{format}, $dt); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 2 | 1; | |||||||||
| 50 | # ABSTRACT: Format DateTime object using DateTimeX::strftimeq | ||||||||||
| 51 | |||||||||||
| 52 | __END__ | ||||||||||