line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::Epoch; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
27559
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
409
|
|
5
|
|
|
|
|
|
|
require Exporter; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@ISA = 'Exporter'; |
8
|
|
|
|
|
|
|
@EXPORT = qw( |
9
|
|
|
|
|
|
|
perl2epoch epoch2perl |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
$VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub perl2epoch { |
15
|
2
|
|
|
2
|
0
|
15
|
my($perlsec, $epoch, @extra) = @_; |
16
|
2
|
|
|
|
|
3
|
my $epochsec; |
17
|
|
|
|
|
|
|
|
18
|
2
|
50
|
|
|
|
6
|
if ($epoch eq 'macos') { |
19
|
2
|
|
|
|
|
6
|
$epochsec = $perlsec + macos_offset(); |
20
|
2
|
|
|
|
|
5
|
$epochsec += tz_offset($extra[0]); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
11
|
return $epochsec; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub epoch2perl { |
28
|
2
|
|
|
2
|
0
|
5
|
my($epochsec, $epoch, @extra) = @_; |
29
|
2
|
|
|
|
|
4
|
my $perlsec; |
30
|
|
|
|
|
|
|
|
31
|
2
|
50
|
|
|
|
6
|
if ($epoch eq 'macos') { |
32
|
2
|
|
|
|
|
5
|
$perlsec = $epochsec - macos_offset(); |
33
|
2
|
|
|
|
|
5
|
$perlsec -= tz_offset($extra[0]); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
10
|
return $perlsec; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub macos_offset () { 2082844800 } |
41
|
|
|
|
|
|
|
sub tz_offset { |
42
|
4
|
|
|
4
|
0
|
6
|
my($offset) = @_; |
43
|
4
|
|
|
|
|
4
|
my $tz_offset; |
44
|
|
|
|
|
|
|
|
45
|
4
|
50
|
|
|
|
9
|
if (defined $offset) { |
46
|
4
|
|
|
|
|
6
|
$tz_offset = $offset * 36; |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
0
|
require Time::Local; |
49
|
0
|
|
|
|
|
0
|
$tz_offset = sprintf "%+0.4d\n", (Time::Local::timelocal(localtime) |
50
|
|
|
|
|
|
|
- Time::Local::timelocal(gmtime)); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
8
|
return $tz_offset; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |