| 1 | |||||||||||||||||||||
| 2 | package Date::Language; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 9 | ▶ | use Time::Local; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 9 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 9 | require Date::Format; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 9 | our $VERSION = '2.35'; # VERSION: generated | |||||||||||||||||||
| 11 | # ABSTRACT: Language specific date formatting and parsing | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 9 | ▶ | use base qw(Date::Format::Generic); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | sub _build_lookups | ||||||||||||||||||||
| 16 | 99 | ▶ | { | ||||||||||||||||||
|
Subroutine
_build_lookups: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 99 | my $pkg = caller; | |||||||||||||||||||
| 18 | 9 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 99 | @{"${pkg}::MoY"}{@{"${pkg}::MoY"}} = (0 .. scalar(@{"${pkg}::MoY"})); | |||||||||||||||||||
| 20 | 99 | @{"${pkg}::MoY"}{@{"${pkg}::MoYs"}} = (0 .. scalar(@{"${pkg}::MoYs"})); | |||||||||||||||||||
| 21 | 99 | @{"${pkg}::DoW"}{@{"${pkg}::DoW"}} = (0 .. scalar(@{"${pkg}::DoW"})); | |||||||||||||||||||
| 22 | 99 | @{"${pkg}::DoW"}{@{"${pkg}::DoWs"}} = (0 .. scalar(@{"${pkg}::DoWs"})); | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | sub new | ||||||||||||||||||||
| 26 | 103 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||
| 27 | 103 | my $self = shift; | |||||||||||||||||||
| 28 | 103 | ▶ | my $type = shift || $self; | ||||||||||||||||||
|
Condition33%1/3
shift() || $self
MC/DC0%0/2
shift() || $self
shift()
$self
Truth table33%1/3
A || B
A= shift()B= $self
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 103 | $type =~ s/^(\w+)$/Date::Language::$1/; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 103 | ▶ | croak "Bad language" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | unless $type =~ /^[\w:]+$/; | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 103 | ▶ | eval "require $type" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | or croak $@; | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 102 | bless [], $type; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | # Stop AUTOLOAD being called ;-) | ||||||||||||||||||||
| 42 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | sub AUTOLOAD | ||||||||||||||||||||
| 45 | 21 | ▶ | { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=3 SCAR=11.2
| |||||||||||||||||||||
| 46 | 21 | our $AUTOLOAD; | |||||||||||||||||||
| 47 | 21 | ▶ | if($AUTOLOAD =~ /::strptime\Z/o) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | { | ||||||||||||||||||||
| 49 | 21 | my $self = $_[0]; | |||||||||||||||||||
| 50 | 21 | ▶ | my $type = ref($self) || $self; | ||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 51 | 21 | require Date::Parse; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 9 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 54 | 21 | *{"${type}::strptime"} = Date::Parse::gen_parser( | |||||||||||||||||||
| 55 | 21 | \%{"${type}::DoW"}, | |||||||||||||||||||
| 56 | 21 | \%{"${type}::MoY"}, | |||||||||||||||||||
| 57 | 21 | \@{"${type}::Dsuf"}, | |||||||||||||||||||
| 58 | 1); | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 21 | goto &{"${type}::strptime"}; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | croak "Undefined method &$AUTOLOAD called"; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 20 | ▶ | sub format_Z { | ||||||||||||||||||
|
Subroutine
format_Z: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 67 | 20 | my $tz = Date::Format::Generic::format_Z(@_); | |||||||||||||||||||
| 68 | 20 | ▶ | my $pkg = ref($_[0]) || 'Date::Language'; | ||||||||||||||||||
|
Condition50%1/2
ref $_[0] || 'Date::Language'
MC/DC0%0/1
ref $_[0] || 'Date::Language'
ref $_[0]
Truth table50%1/2
A
A= ref $_[0]
| |||||||||||||||||||||
| 69 | 9 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 70 | 20 | my $tz_map = \%{"${pkg}::TZ"}; | |||||||||||||||||||
| 71 | 20 | ▶ | return exists $tz_map->{$tz} ? $tz_map->{$tz} : $tz; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | sub str2time | ||||||||||||||||||||
| 75 | 26 | ▶ | { | ||||||||||||||||||
|
Subroutine
str2time: called CC=10 SCAR=24.2
Pod
documented
| |||||||||||||||||||||
| 76 | 26 | my $me = shift; | |||||||||||||||||||
| 77 | 26 | my @t = $me->strptime(@_); | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | return undef | ||||||||||||||||||||
| 80 | 26 | ▶ | unless @t; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 26 | my($ss,$mm,$hh,$day,$month,$year,$zone) = @t; | |||||||||||||||||||
| 83 | 26 | my @lt = localtime(time); | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 26 | ▶ | $hh ||= 0; | ||||||||||||||||||
|
Condition100%2/2
$hh ||= 0
MC/DC100%1/1
$hh ||= 0
$hh
Truth table100%2/2
A
A= $hh
| |||||||||||||||||||||
| 86 | 26 | ▶ | $mm ||= 0; | ||||||||||||||||||
|
Condition100%2/2
$mm ||= 0
MC/DC100%1/1
$mm ||= 0
$mm
Truth table100%2/2
A
A= $mm
| |||||||||||||||||||||
| 87 | 26 | ▶ | $ss ||= 0; | ||||||||||||||||||
|
Condition100%2/2
$ss ||= 0
MC/DC100%1/1
$ss ||= 0
$ss
Truth table100%2/2
A
A= $ss
| |||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 26 | ▶ | $month = $lt[4] | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | unless(defined $month); | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 26 | ▶ | $day = $lt[3] | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 93 | unless(defined $day); | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 26 | ▶ | $year = ($month > $lt[4]) ? ($lt[5] - 1) : $lt[5] | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 96 | unless(defined $year); | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 26 | ▶ | return defined $zone ? timegm($ss,$mm,$hh,$day,$month,$year) - $zone | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | : timelocal($ss,$mm,$hh,$day,$month,$year); | ||||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 9 | 1; | |||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||