blib/lib/Database/BI/Util.pm

filter: Statementstmt 64.0% 57 / 89 Branchbran 41.6% 25 / 60 Conditioncond 20.3% 13 / 64 MC/DCmcdc 18.1% 6 / 33 Subroutinesub 81.2% 13 / 16 Podpod 100% 8 / 8 totaltotal 45.1% 122 / 270 CC 54 SCAR 46.5
CC
54
Cov
45%
_in_zone
306.0
parse_zone
132.9
_days_from_civil
20.0
CRAP 104.7
« blib/lib/Database/BI/Controller/Dashboard.pm ↑ Summary blib/lib/Database/BI/Model/DataSource.pm »
1 package Database::BI::Util;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 our $VERSION = '0.024.0';
7  
8 13 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 our @EXPORT_OK = qw( urlencode parse_number iso_datetime minute_stamp iso8601_utc
14 parse_zone zone_wall frame_epoch );
15  
16 # A list rather than any three capitals, or 'SKU 100' would be read as 100.
17 13 Readonly my $CURRENCY_CODES => join '|', qw(AUD BRL CAD CHF CNY DKK EUR GBP HKD INR JPY MXN NOK NZD SEK SGD USD ZAR);
18 # The largest number a chart can use: a C double's, which is what the browser
19 # has (parseAccounting refuses what is not isFinite there). Not perl's own
20 # infinity: a perl built with -Duselongdouble or -Dusequadmath holds 1e999 as
21 # a finite number, so comparing with infinity let it through on those perls
22 # alone (GitHub issue 6).
23 13 Readonly my $LARGEST_NUMBER => POSIX::DBL_MAX();
24  
25 # A date, or a date and a time with T or a space between them; the time may
26 # carry seconds, a fraction of a second, and a zone (Z, or an offset such as
27 # +01:00, +0100 or +01). The last three are what JSON APIs and exports write.
28 13 Readonly my $ISO_DATETIME_RE => qr{
29 \A (\d{4}-\d{2}-\d{2})
30 (?: [T ] (\d{2}) : (\d{2}) (?: : (\d{2}) (?: [.,] \d+ )? )?
31 ( [Zz] | [+-] \d{2} (?: :? \d{2} )? )? )?
32 \z
33 }x;
34  
35 # Premise 1: iso_datetime runs once per cell of a date filter, time range or
36 # formula.
37 # Premise 2: reading a Readonly scalar costs several times a plain lexical's,
38 # and a compiled regex is the same object either way.
39 # Conclusion: the hot path matches against a lexical copy; the Readonly stays
40 # the one definition, so the pattern is still written once.
41 13 my $ISO_DATETIME_FAST = $ISO_DATETIME_RE;
42  
43 # urlencode($str) -> $encoded
44 #
45 # Percent-encodes a string for use as a URI query-parameter value.
46 # Preserves only the RFC 3986 unreserved characters (letters, digits,
47 # hyphen, dot, underscore, tilde) and encodes everything else as %XX.
48 #
49 # Why a shared copy rather than Mojo::Util::url_escape:
50 # Ask.pm and Insights.pm are plain Perl modules with no Mojo dependency;
51 # pulling in Mojo::Util for a 3-line function would be an undue coupling.
52 #
53 # Multi-byte characters: a decoded string is encoded to its UTF-8 bytes first,
54 # because ord() returns the codepoint and U+263A would print as "%263A", which
55 # decodes to "&3A". A string of bytes (the usual CSV cell) is left as it is, so
56 # text that is already UTF-8 is not encoded twice.
57 268 ▶sub urlencode {
Subroutine urlencode: called CC=3 SCAR=11.0
Pod documented
58 268 my ($str) = @_;
59 268 ▶ return '' unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 3 265 268
60 265 ▶ utf8::encode($str) if utf8::is_utf8($str);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($str) 2 263 265
61 # '-' placed at end of character class to avoid ambiguity with a range.
62 265 $str =~ s/([^A-Za-z0-9._~-])/sprintf('%%%02X', ord($1))/ge;
63 265 return $str;
64 }
65  
66 # Only what dresses up a number is removed: spaces, brackets, thousands
67 # separators, a percent sign, currency symbols and a known currency code. Any
68 # other letter stays and fails the match, so 'SKU123' and 'AB-100' are text
69 # rather than 123 and -100. The bracket is read before it is removed.
70 # The browser's parseAccounting (layouts/parse_accounting.html.tt) is a copy,
71 # so a table sorts the same on the server as on the page: change one, change
72 # the other.
73 8035 ▶sub parse_number {
Subroutine parse_number: called CC=8 SCAR=20.8
Pod documented
74 8035 my $value = $_[0];
75  
76 8035 ▶ return undef unless defined($value) && length($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 27 8008 8035
Condition100%3/3
defined $value and length $value
!ll&&!rl&&r
9188008
MC/DC100%2/2
defined $value and length $value
defined $value length $value
Truth table100%3/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
77  
78 # Premise 1: the slow path below only removes spaces, brackets, commas, $, %,
79 # non-ASCII and currency codes before matching a plain decimal.
80 # Premise 2: an ASCII plain decimal contains none of those.
81 # Premise 3: at most 300 integer digits is below 1e300, under DBL_MAX.
82 # Conclusion: such a cell reaches the same number without the substitutions
83 # or the range check (a Readonly read costs several times a
84 # lexical's); longer ones take the full path.
85 8008 ▶ return $value + 0 if $value =~ /\A-?[0-9]{1,300}(?:\.[0-9]+)?\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\A-?[0-9]{1,300}(?:\.[0-9]+)?\z/ 6103 1905 8008
86  
87 1905 my $is_accounting = ($value =~ /\A\s*\(/);
88 1905 (my $text = $value) =~ s/(?:\A|(?<=[\s(]))(?:$CURRENCY_CODES)(?=[\s\d.])|(?<=[\s\d])(?:$CURRENCY_CODES)(?=[\s)]|\z)//g;
89 1905 $text =~ s/[\s(),\$%]|[^\x00-\x7F]//g;
90 1905 ▶ $text = "-$text" if $is_accounting && $text =~ /\A\d/;
Branch: 1 branch
BranchTrueFalseTotal
if $is_accounting and $text =~ /\A\d/ 29 1876 1905
Condition100%3/3
$is_accounting and $text =~ /\A\d/
!ll&&!rl&&r
1871529
MC/DC100%2/2
$is_accounting and $text =~ /\A\d/
$is_accounting $text =~ /\A\d/
Truth table100%3/3
A and B
A= $is_accountingB= $text =~ /\A\d/
ABresult
0X0
100
111
91 1905 ▶ return undef unless $text =~ /\A-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $text =~ /\A-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?\z/ 1798 107 1905
92  
93 107 my $number = $text + 0;
94  
95 # 1e999 spells a number, but one past a double's range is infinity in the
96 # browser, which is no use to a total or an axis -- on every perl.
97 107 ▶ return undef unless abs($number) <= $LARGEST_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless abs $number <= $LARGEST_NUMBER 11 96 107
98 96 return $number;
99 }
100  
101 # The zone the server works in, or undef (the default: a time is as written).
102 # A { kind => 'fixed', offset => seconds } or { kind => 'local' } from
103 # parse_zone. The app's around_dispatch hook sets it with `local` from config
104 # time_zone, so it is the one setting every reader of a time sees.
105 13 our $ZONE;
106  
107 # parse_zone($spec) -> \%zone | undef
108 #
109 # 'UTC' (or 'Z', 'GMT'), 'local' (the server's own zone, daylight saving
110 # included), or a fixed offset: +05:30, -0800, +01. undef and '' are no zone.
111 # Anything else croaks, so a typo in the configuration stops the start.
112 145 ▶sub parse_zone {
Subroutine parse_zone: called CC=13 SCAR=48.9
Pod documented
113 145 my ($spec) = @_;
114 145 ▶ return undef unless defined $spec && length $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spec and length $spec 145 0 145
Condition33%1/3
defined $spec and length $spec
!ll&&!rl&&r
14500
MC/DC0%0/2
defined $spec and length $spec
defined $spec length $spec
Truth table33%1/3
A and B
A= defined $specB= length $spec
ABresult
0X0
100
111
115 0 ▶ croak "time_zone: '" . (ref $spec || $spec) . "' is not UTC, local, or an offset such as +05:30"
Branch: 1 branch
BranchTrueFalseTotal
if ref $spec 0 0 0
Condition0%0/3
ref $spec || $spec
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $spec || $spec
ref $spec $spec
Truth table0%0/3
A || B
A= ref $specB= $spec
ABresult
1X1
011
000
116 if ref $spec;
117 0 ▶ return { kind => 'fixed', offset => 0 } if $spec =~ /\A(?:utc|gmt|z)\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if $spec =~ /\A(?:utc|gmt|z)\z/i 0 0 0
118 0 ▶ return { kind => 'local' } if $spec =~ /\Alocal\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if $spec =~ /\Alocal\z/i 0 0 0
119 0 ▶ if (my ($sign, $hh, $mm) = $spec =~ /\A([+-])([0-9]{2})(?::?([0-9]{2}))?\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $spec =~ /\A([+-])([0-9]{2})(?::?([0-9]{2}))?\z/) 0 0 0
120 0 ▶ croak "time_zone: '$spec' is not UTC, local, or an offset such as +05:30"
Branch: 1 branch
BranchTrueFalseTotal
unless $hh <= 14 and ($mm // 0) <= 59 0 0 0
Condition0%0/5
$hh <= 14 and ($mm // 0) <= 59
!ll&&!rl&&r
000
$mm // 0
l!l
00
MC/DC0%0/2
$hh <= 14 and ($mm // 0) <= 59
$hh <= 14 $mm
Truth table0%0/3
A and B
A= $hh <= 14B= $mm
ABresult
0X0
100
111
121 unless $hh <= 14 && ($mm // 0) <= 59;
122 0 ▶ my $secs = $hh * 3_600 + ($mm // 0) * 60;
Condition0%0/2
$mm // 0
l!l
00
MC/DC0%0/1
$mm // 0
$mm
Truth table0%0/2
A
A= $mm
Aresult
11
00
123 0 ▶ return { kind => 'fixed', offset => $sign eq '-' ? -$secs : $secs };
Branch: 1 branch
BranchTrueFalseTotal
$sign eq '-' ? : 0 0 0
124 }
125 0 croak "time_zone: '$spec' is not UTC, local, or an offset such as +05:30";
126 }
127  
128 # zone_wall($epoch) -> (sec, min, hour, mday, mon, year, wday, yday, isdst)
129 #
130 # What localtime gives, but in the configured zone: the clock on the wall
131 # there at that moment. With no zone it is localtime.
132 0 ▶sub zone_wall {
Subroutine zone_wall: not called CC=3 SCAR=24.8
Pod documented
133 0 my ($epoch) = @_;
134 0 local $!; # localtime's tzset may leave errno set; see Calc::_epoch_of
135 return ($ZONE && $ZONE->{kind} eq 'fixed')
136 ? gmtime($epoch + $ZONE->{offset})
137 0 ▶ : localtime($epoch);
Branch: 1 branch
BranchTrueFalseTotal
$Database::BI::Util::ZONE && $Database::BI::Util::ZONE->{'kind'} eq 'fixed' ? : 0 0 0
Condition0%0/3
$Database::BI::Util::ZONE and $Database::BI::Util::ZONE->{"kind"} eq "fixed"
!ll&&!rl&&r
000
MC/DC0%0/2
$Database::BI::Util::ZONE and $Database::BI::Util::ZONE->{"kind"} eq "fixed"
$Database::BI::Util::ZONE $Database::BI::Util::ZONE->{"kind"} eq "fixed"
Truth table0%0/3
A and B
A= $Database::BI::Util::ZONEB= $Database::BI::Util::ZONE->{"kind"} eq "fixed"
ABresult
0X0
100
111
138 }
139  
140 # frame_epoch($epoch) -> $epoch'
141 #
142 # The date code (Calc, the time range) reads a clock with localtime and builds
143 # one with mktime, so it lives in the server's zone. For a time read in
144 # another zone this gives the epoch whose localtime shows that zone's wall
145 # clock; with no zone, or the server's own, it is $epoch.
146 39559 ▶sub frame_epoch {
Subroutine frame_epoch: called CC=4 SCAR=22.3
Pod documented
147 39559 my ($epoch) = @_;
148 39559 ▶ return $epoch unless $ZONE && $ZONE->{kind} eq 'fixed';
Branch: 1 branch
BranchTrueFalseTotal
unless $Database::BI::Util::ZONE and $Database::BI::Util::ZONE->{"kind"} eq "fixed" 39559 0 39559
Condition33%1/3
$Database::BI::Util::ZONE and $Database::BI::Util::ZONE->{"kind"} eq "fixed"
!ll&&!rl&&r
3955900
MC/DC0%0/2
$Database::BI::Util::ZONE and $Database::BI::Util::ZONE->{"kind"} eq "fixed"
$Database::BI::Util::ZONE $Database::BI::Util::ZONE->{"kind"} eq "fixed"
Truth table33%1/3
A and B
A= $Database::BI::Util::ZONEB= $Database::BI::Util::ZONE->{"kind"} eq "fixed"
ABresult
0X0
100
111
149 0 my @wall = zone_wall($epoch);
150 0 local $!;
151 0 ▶ return POSIX::mktime(@wall[0 .. 5]) // $epoch;
Condition0%0/3
POSIX::mktime(@wall[0..5]) // $epoch
l!l&&r!l&&!r
000
MC/DC0%0/2
POSIX::mktime(@wall[0..5]) // $epoch
POSIX::mktime(@wall[0..5]) $epoch
Truth table0%0/3
A // B
A= POSIX::mktime(@wall[0..5])B= $epoch
ABresult
1X1
011
000
152 }
153  
154 # _days_from_civil($y, $m, $d) -> days since 1970-01-01 (proleptic Gregorian)
155 0 ▶sub _days_from_civil {
Subroutine _days_from_civil: not called CC=4 SCAR=30.0
156 0 my ($y, $m, $d) = @_;
157 0 ▶ $y -= $m <= 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$m <= 2 ? : 0 0 0
158 0 ▶ my $era = int(($y >= 0 ? $y : $y - 399) / 400);
Branch: 1 branch
BranchTrueFalseTotal
$y >= 0 ? : 0 0 0
159 0 my $yoe = $y - $era * 400;
160 0 ▶ my $doy = int((153 * ($m + ($m > 2 ? -3 : 9)) + 2) / 5) + $d - 1;
Branch: 1 branch
BranchTrueFalseTotal
$m > 2 ? : 0 0 0
161 0 my $doe = $yoe * 365 + int($yoe / 4) - int($yoe / 100) + $doy;
162 0 return $era * 146_097 + $doe - 719_468;
163 }
164  
165 # _in_zone($day, $hour, $minute, $second, $zone_text) -> ($day, $h, $m, $s)
166 #
167 # Premise 1: a value that names a zone names one moment.
168 # Premise 2: a configured zone is the clock the reader works to.
169 # Conclusion: the written time is moved to that zone's clock, and the day may
170 # change with it. A date or time that cannot exist (a 31st of
171 # February, hour 25) is left as written: the callers that need a
172 # real one refuse it, and arithmetic would make it another day.
173 0 ▶sub _in_zone {
Subroutine _in_zone: not called CC=17 SCAR=57.2
174 0 my ($day, $hour, $minute, $second, $zone_text) = @_;
175 0 my ($y, $mon, $dom) = split /-/, $day;
176 0 ▶ my @dim = (31, (($y % 4 == 0 && $y % 100 != 0) || $y % 400 == 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
Branch: 1 branch
BranchTrueFalseTotal
$y % 4 == 0 && $y % 100 != 0 || $y % 400 == 0 ? : 0 0 0
Condition0%0/6
$y % 4 == 0 and $y % 100 != 0 or $y % 400 == 0
l!l&&r!l&&!r
000
$y % 4 == 0 and $y % 100 != 0
!ll&&!rl&&r
000
MC/DC0%0/3
$y % 4 == 0 and $y % 100 != 0 or $y % 400 == 0
$y % 4 == 0 $y % 100 != 0 $y % 400 == 0
Truth table0%0/5
A and B or C
A= $y % 4 == 0B= $y % 100 != 0C= $y % 400 == 0
ABCresult
11X1
0X11
1011
0X00
1000
177 0 ▶ return ($day, $hour, $minute, $second)
Branch: 1 branch
BranchTrueFalseTotal
unless $mon >= 1 and $mon <= 12 and $dom >= 1 and $dom <= $dim[$mon - 1] and $hour <= 23 and $minute <= 59 and ($second // 0) <= 59 0 0 0
Condition0%0/20
$mon >= 1 and $mon <= 12 and $dom >= 1 and $dom <= $dim[$mon - 1] and $hour <= 23 and $minute <= 59 and ($second // 0) <= 59
!ll&&!rl&&r
000
$mon >= 1 and $mon <= 12 and $dom >= 1 and $dom <= $dim[$mon - 1] and $hour <= 23 and $minute <= 59
!ll&&!rl&&r
000
$mon >= 1 and $mon <= 12 and $dom >= 1 and $dom <= $dim[$mon - 1] and $hour <= 23
!ll&&!rl&&r
000
$mon >= 1 and $mon <= 12 and $dom >= 1 and $dom <= $dim[$mon - 1]
!ll&&!rl&&r
000
$mon >= 1 and $mon <= 12 and $dom >= 1
!ll&&!rl&&r
000
$mon >= 1 and $mon <= 12
!ll&&!rl&&r
000
$second // 0
l!l
00
MC/DC0%0/7
$mon >= 1 and $mon <= 12 and $dom >= 1 and $dom <= $dim[$mon - 1] and $hour <= 23 and $minute <= 59 and ($second // 0) <= 59
$mon >= 1 $mon <= 12 $dom >= 1 $dom <= $dim[$mon - 1] $hour <= 23 $minute <= 59 $second
Truth table0%0/8
A and B and C and D and E and F and G
A= $mon >= 1B= $mon <= 12C= $dom >= 1D= $dom <= $dim[$mon - 1]E= $hour <= 23F= $minute <= 59G= $second
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11110XX0
111110X0
11111100
11111111
178 unless $mon >= 1 && $mon <= 12 && $dom >= 1 && $dom <= $dim[$mon - 1]
179 && $hour <= 23 && $minute <= 59 && ($second // 0) <= 59;
180  
181 0 my $from = 0;
182 0 ▶ if ($zone_text =~ /\A([+-])([0-9]{2}):?([0-9]{2})?\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($zone_text =~ /\A([+-])([0-9]{2}):?([0-9]{2})?\z/) 0 0 0
183 0 ▶ $from = ($2 * 3_600 + ($3 // 0) * 60) * ($1 eq '-' ? -1 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$1 eq '-' ? : 0 0 0
Condition0%0/2
$3 // 0
l!l
00
MC/DC0%0/1
$3 // 0
$3
Truth table0%0/2
A
A= $3
Aresult
11
00
184 }
185 0 ▶ my $epoch = _days_from_civil($y + 0, $mon + 0, $dom + 0) * 86_400
Condition0%0/2
$second // 0
l!l
00
MC/DC0%0/1
$second // 0
$second
Truth table0%0/2
A
A= $second
Aresult
11
00
186 + $hour * 3_600 + $minute * 60 + ($second // 0) - $from;
187 0 my @wall = zone_wall($epoch);
188 return (
189 0 ▶ sprintf('%04d-%02d-%02d', $wall[5] + 1900, $wall[4] + 1, $wall[3]),
Branch: 1 branch
BranchTrueFalseTotal
defined $second ? : 0 0 0
190 sprintf('%02d', $wall[2]),
191 sprintf('%02d', $wall[1]),
192 defined $second ? sprintf('%02d', $wall[0]) : undef,
193 );
194 }
195  
196 # iso_datetime($value) -> ($day, $hour, $minute, $second) | ()
197 #
198 # The one reading of an ISO date or timestamp, for the filters, the time range
199 # and the formulas alike. A fraction of a second is set aside. A time that
200 # names a zone (Z, +01:00) is moved to the configured zone ($ZONE, config
201 # time_zone) when there is one, so 2026-11-06T23:30:00Z is 18:30 on the 6th
202 # for -05:00; with no zone configured, or a time with none written, the time
203 # is taken as written and the value is the day the table shows.
204 3827 ▶sub iso_datetime {
Subroutine iso_datetime: called CC=7 SCAR=20.7
Pod documented
205 3827 my ($value) = @_;
206 3827 ▶ return () unless defined $value && !ref $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value 8 3819 3827
Condition100%3/3
defined $value and not ref $value
!ll&&!rl&&r
443819
MC/DC100%2/2
defined $value and not ref $value
defined $value not ref $value
Truth table100%3/3
A and not(B)
A= defined $valueB= not ref $value
ABresult
0X0
100
111
207 3819 ▶ my ($day, $hour, $minute, $second, $zone) = $value =~ $ISO_DATETIME_FAST or return ();
Branch: 1 branch
BranchTrueFalseTotal
() = $value =~ /$ISO_DATETIME_FAST/ or return () 1669 2150 3819
208 1669 ▶ return ($day, $hour, $minute, $second) unless defined $zone && $ZONE;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $zone and $Database::BI::Util::ZONE 1669 0 1669
Condition66%2/3
defined $zone and $Database::BI::Util::ZONE
!ll&&!rl&&r
166360
MC/DC0%0/2
defined $zone and $Database::BI::Util::ZONE
defined $zone $Database::BI::Util::ZONE
Truth table66%2/3
A and B
A= defined $zoneB= $Database::BI::Util::ZONE
ABresult
0X0
100
111
209 0 ▶ return _in_zone($day, $hour, $minute, $second, $zone =~ /\A[Zz]\z/ ? '+00:00' : $zone);
Branch: 1 branch
BranchTrueFalseTotal
$zone =~ /\A[Zz]\z/ ? : 0 0 0
210 }
211  
212 # minute_stamp(@tm) -> 'YYYY-MM-DD HH:MM'
213 # iso8601_utc($epoch) -> 'YYYY-MM-DDTHH:MM:SSZ'
214 #
215 # Written with sprintf rather than POSIX::strftime: on Windows, perl 5.38's
216 # strftime did not return (CI sat in t/function.t until the job's limit),
217 # and these fixed formats need nothing from the C library.
218 220 ▶sub minute_stamp {
Subroutine minute_stamp: called CC=2 SCAR=6.9
Pod documented
219 220 my @tm = @_;
220 220 ▶ return '' unless @tm >= 6;
Branch: 1 branch
BranchTrueFalseTotal
unless @tm >= 6 2 218 220
221 218 return sprintf '%04d-%02d-%02d %02d:%02d', $tm[5] + 1900, $tm[4] + 1, $tm[3], $tm[2], $tm[1];
222 }
223  
224 27 ▶sub iso8601_utc {
Subroutine iso8601_utc: called CC=2 SCAR=6.9
Pod documented
225 27 my ($epoch) = @_;
226 27 ▶ my @tm = gmtime(defined $epoch ? $epoch : time);
Branch: 1 branch
BranchTrueFalseTotal
defined $epoch ? : 3 24 27
227 27 return sprintf '%04d-%02d-%02dT%02d:%02d:%02dZ', $tm[5] + 1900, $tm[4] + 1, $tm[3], $tm[2], $tm[1], $tm[0];
228 }
229  
230 13 1;
231  
232 __END__
« blib/lib/Database/BI/Controller/Dashboard.pm ↑ Summary blib/lib/Database/BI/Model/DataSource.pm »