| 1 | package App::SimpleBackuper; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Exporter qw(import); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | our @EXPORT = qw(fmt_weight fmt_datetime fmt_time fmt_hex2base64); | |||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub fmt_weight { | ||||||||
|
Subroutine
fmt_weight: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 10 | 0 | my($weight) = @_; | |||||||||
| 11 | 0 | my $unit = 'b'; | |||||||||
| 12 | 0 | foreach my $u (qw(Kb Mb Gb Tb Pb)) { | |||||||||
| 13 | 0 | ▶ | last if $weight < 1000; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | $weight /= 1000; | |||||||||
| 15 | 0 | $unit = $u; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | if(int(($weight - int($weight)) * 10) == 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | return int($weight).$unit; | |||||||||
| 20 | } else { | ||||||||||
| 21 | 0 | return sprintf("%.1f%s", $weight, $unit); | |||||||||
| 22 | } | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub fmt_datetime { | ||||||||
|
Subroutine
fmt_datetime: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 26 | 0 | my @dt = localtime(shift); | |||||||||
| 27 | 0 | return sprintf "%04u-%02u-%02u %02u:%02u:%02u", $dt[5] + 1900, $dt[4] + 1, $dt[3], $dt[2], $dt[1], $dt[0]; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub fmt_time { | ||||||||
|
Subroutine
fmt_time: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 31 | 0 | my $seconds = shift; | |||||||||
| 32 | 0 | my $minutes = int($seconds / 60); | |||||||||
| 33 | 0 | ▶ | return int($seconds).'s' if ! $minutes; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | $seconds -= $minutes * 60; | |||||||||
| 36 | 0 | my $hours = int($minutes / 60); | |||||||||
| 37 | 0 | ▶ | return sprintf "%02d:%02d", $minutes, $seconds if ! $hours; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | $minutes -= $hours * 60; | |||||||||
| 40 | 0 | my $days = int($hours / 24); | |||||||||
| 41 | 0 | ▶ | return sprintf "%02d:%02d:%02d", $hours, $minutes, $seconds if ! $days; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | |||||||||||
| 43 | 0 | $hours -= $days * 24; | |||||||||
| 44 | 0 | return sprintf "%dd %02d:%02d:%02d", $days, $hours, $minutes, $seconds; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 1 | ▶ | use MIME::Base64; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 48 | 0 | ▶ | sub fmt_hex2base64 { MIME::Base64::encode_base64url(pack "h*", shift) } | ||||||||
|
Subroutine
fmt_hex2base64: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||