← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:34:56 2016
Reported on Thu Jun 30 16:35:09 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/DateTime/Locale/Util.pm
StatementsExecuted 9 statements in 298µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11119µs22µsDateTime::Locale::Util::::BEGIN@3DateTime::Locale::Util::BEGIN@3
1119µs20µsDateTime::Locale::Util::::BEGIN@6DateTime::Locale::Util::BEGIN@6
1117µs11µsDateTime::Locale::Util::::BEGIN@4DateTime::Locale::Util::BEGIN@4
0000s0sDateTime::Locale::Util::::_tcDateTime::Locale::Util::_tc
0000s0sDateTime::Locale::Util::::parse_locale_codeDateTime::Locale::Util::parse_locale_code
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::Locale::Util;
2
3223µs224µs
# spent 22µs (19+2) within DateTime::Locale::Util::BEGIN@3 which was called: # once (19µs+2µs) by DateTime::Locale::FromData::BEGIN@6 at line 3
use strict;
# spent 22µs making 1 call to DateTime::Locale::Util::BEGIN@3 # spent 2µs making 1 call to strict::import
4223µs215µs
# spent 11µs (7+4) within DateTime::Locale::Util::BEGIN@4 which was called: # once (7µs+4µs) by DateTime::Locale::FromData::BEGIN@6 at line 4
use warnings;
# spent 11µs making 1 call to DateTime::Locale::Util::BEGIN@4 # spent 4µs making 1 call to warnings::import
5
62247µs231µs
# spent 20µs (9+11) within DateTime::Locale::Util::BEGIN@6 which was called: # once (9µs+11µs) by DateTime::Locale::FromData::BEGIN@6 at line 6
use Exporter qw( import );
# spent 20µs making 1 call to DateTime::Locale::Util::BEGIN@6 # spent 11µs making 1 call to Exporter::import
7
81400nsour $VERSION = '1.03';
9
1011µsour @EXPORT_OK = 'parse_locale_code';
11
12sub parse_locale_code {
13 my @pieces = split /-/, $_[0];
14
15 return unless @pieces;
16
17 my %codes = ( language => lc shift @pieces );
18 if ( @pieces == 1 ) {
19 if ( length $pieces[0] == 2 || $pieces[0] =~ /^\d\d\d$/ ) {
20 $codes{territory} = uc shift @pieces;
21 }
22 }
23 elsif ( @pieces == 3 ) {
24 $codes{script} = _tc( shift @pieces );
25 $codes{territory} = uc shift @pieces;
26 $codes{variant} = uc shift @pieces;
27 }
28 elsif ( @pieces == 2 ) {
29
30 # I don't think it's possible to have a script + variant with also
31 # having a territory.
32 if ( length $pieces[1] == 2 || $pieces[1] =~ /^\d\d\d$/ ) {
33 $codes{script} = _tc( shift @pieces );
34 $codes{territory} = uc shift @pieces;
35 }
36 else {
37 $codes{territory} = uc shift @pieces;
38 $codes{variant} = uc shift @pieces;
39 }
40 }
41
42 return %codes;
43}
44
45sub _tc {
46 return ucfirst lc $_[0];
47}
48
4913µs1;
50
51# ABSTRACT: Utility code for DateTime::Locale
52
53__END__