blib/lib/SMB/Time.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 28 SCAR 6.9
CC
1
Cov
0%
from_nttime
2.0
to_nttime
2.0
BEGIN
2.0
CRAP 2.0
1 # SMB-Perl library, Copyright (C) 2014 Mikhael Goikhman, migo@cpan.org
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15  
16 package SMB::Time;
17  
18 use strict;
19 use warnings;
20  
21 # bigint conflicts with Time::HiRes::time, prefer to lose precision for now
22 #use if (1 << 32 == 1), 'bigint'; # support native uint64 on 32-bit platforms
23  
24 use Exporter 'import';
25 our @EXPORT = qw(from_nttime to_nttime);
26  
27 my $nttime_factor = 10_000_000;
28 my $nttime_offset = 11_644_473_600;
29  
30 sub from_nttime ($) {
31 my $nttime = shift || return 0;
32  
33 return $nttime / $nttime_factor - $nttime_offset;
34 }
35  
36 sub to_nttime ($) {
37 my $time = shift || return 0;
38  
39 return ($time + $nttime_offset) * $nttime_factor;
40 }
41  
42 1;
43  
44 __END__