blib/lib/POSIX/1003/Time.pm

filter: Statementstmt 73.5% 25 / 34 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 58.1% 32 / 55 CC 5 SCAR 26.5
CC
5
Cov
57%
strftime
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 14.2
« blib/lib/POSIX/1003/Limit.pm ↑ Summary blib/lib/POSIX/1003/Pathconf.pm »
1 # Copyrights 2011-2013 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package POSIX::1003::Time;
9 3 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 $VERSION = '0.98';
11  
12 3 ▶use base 'POSIX::1003::Module';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use POSIX::1003::Locale qw(setlocale LC_TIME);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Encode qw(find_encoding is_utf8 decode);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # Blocks resp. defined in time.h, limits.h
18 1 my @constants = qw/
19 CLK_TCK CLOCKS_PER_SEC NULL
20 TZNAME_MAX
21 /;
22  
23 1 our @IN_CORE = qw/gmtime localtime/;
24  
25 1 my @functions = qw/
26 asctime ctime strftime
27 clock difftime mktime
28 tzset tzname/;
29 1 push @functions, @IN_CORE;
30  
31 1 our %EXPORT_TAGS =
32 ( constants => \@constants
33 , functions => \@functions
34 );
35  
36  
37 sub strftime($@)
38 0 ▶{ my $fmt = shift;
Subroutine strftime: not called CC=5 SCAR=34.0
Pod documented
39  
40 #XXX See https://github.com/abeltje/lc_time for the correct implementation,
41 # using nl_langinfo(CODESET)
42  
43 0 my $lc = setlocale LC_TIME;
44 0 ▶ if($lc && $lc =~ m/\.([\w-]+)/ && (my $enc = find_encoding $1))
Branch: 1 branch
BranchTrueFalseTotal
if ($lc and $lc =~ /\.([\w-]+)/ and my $enc = &find_encoding($1)) 0 0 0
Condition0%0/6
$lc and $lc =~ /\.([\w-]+)/ and my $enc = &find_encoding($1)
!ll&&!rl&&r
000
$lc and $lc =~ /\.([\w-]+)/
!ll&&!rl&&r
000
MC/DC0%0/3
$lc and $lc =~ /\.([\w-]+)/ and my $enc = &find_encoding($1)
$lc $lc =~ /\.([\w-]+)/ my $enc = &find_encoding($1)
Truth table0%0/4
A and B and C
A= $lcB= $lc =~ /\.([\w-]+)/C= my $enc = &find_encoding($1)
ABCresult
0XX0
10X0
1100
1111
45 { # enforce the format string (may contain any text) to the same
46 # charset as the locale is using.
47 0 my $rawfmt = $enc->encode($fmt);
48 0 return $enc->decode(POSIX::strftime($rawfmt, @_));
49 }
50  
51 0 ▶ if(is_utf8($fmt))
Branch: 1 branch
BranchTrueFalseTotal
if (&is_utf8($fmt)) 0 0 0
52 { # no charset in locale, hence ascii inserts
53 0 my $out = POSIX::strftime(encode($fmt, 'utf8'), @_);
54 0 return decode $out, 'utf8';
55 }
56  
57 # don't know about the charset
58 0 POSIX::strftime($fmt, @_);
59 }
60  
61  
62 # Everything in POSIX.xs
63  
64  
65 1 1;
« blib/lib/POSIX/1003/Limit.pm ↑ Summary blib/lib/POSIX/1003/Pathconf.pm »