line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flower::Chronos::Utils; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
20223
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use base 'Exporter'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
232
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(are_hashes_equal parse_time); |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
826
|
use Time::Piece; |
|
2
|
|
|
|
|
14856
|
|
|
2
|
|
|
|
|
22
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub are_hashes_equal { |
13
|
6
|
|
|
6
|
0
|
6359
|
my ($first, $second) = @_; |
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
|
|
18
|
foreach my $key (keys %$first) { |
16
|
5
|
100
|
100
|
|
|
39
|
if (defined $first->{$key} && defined $second->{$key}) { |
|
|
100
|
66
|
|
|
|
|
17
|
2
|
100
|
|
|
|
7
|
if ($first->{$key} ne $second->{$key}) { |
18
|
1
|
|
|
|
|
5
|
return 0; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif (!defined $first->{$key} && !defined $second->{$key}) { |
22
|
1
|
|
|
|
|
3
|
next; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
2
|
|
|
|
|
8
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
11
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub parse_time { |
33
|
18
|
|
|
18
|
0
|
2670
|
my ($string) = @_; |
34
|
|
|
|
|
|
|
|
35
|
18
|
100
|
|
|
|
85
|
return $string if $string =~ m/^\d+$/; |
36
|
|
|
|
|
|
|
|
37
|
16
|
|
|
|
|
22
|
my $format = '%Y-%m-%d'; |
38
|
16
|
100
|
|
|
|
47
|
if ($string =~ m/ \d\d:\d\d:\d\d$/) { |
39
|
3
|
|
|
|
|
8
|
$format .= ' %T'; |
40
|
|
|
|
|
|
|
} |
41
|
16
|
|
|
|
|
71
|
return Time::Piece->strptime($string, $format)->epoch; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |