line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flower::Chronos::Utils; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
20965
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use base 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
230
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(are_hashes_equal parse_time); |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
838
|
use Time::Piece; |
|
2
|
|
|
|
|
15431
|
|
|
2
|
|
|
|
|
22
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub are_hashes_equal { |
13
|
6
|
|
|
6
|
0
|
6810
|
my ($first, $second) = @_; |
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
|
|
20
|
foreach my $key (keys %$first) { |
16
|
5
|
100
|
100
|
|
|
43
|
if (defined $first->{$key} && defined $second->{$key}) { |
|
|
100
|
66
|
|
|
|
|
17
|
2
|
100
|
|
|
|
9
|
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
|
|
|
|
|
9
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
12
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub parse_time { |
33
|
18
|
|
|
18
|
0
|
2845
|
my ($string) = @_; |
34
|
|
|
|
|
|
|
|
35
|
18
|
100
|
|
|
|
80
|
return $string if $string =~ m/^\d+$/; |
36
|
|
|
|
|
|
|
|
37
|
16
|
|
|
|
|
25
|
my $format = '%Y-%m-%d'; |
38
|
16
|
100
|
|
|
|
43
|
if ($string =~ m/ \d\d:\d\d:\d\d$/) { |
39
|
3
|
|
|
|
|
6
|
$format .= ' %T'; |
40
|
|
|
|
|
|
|
} |
41
|
16
|
|
|
|
|
70
|
return Time::Piece->strptime($string, $format)->epoch; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |