| 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 | 5 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 5 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 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 | 5 | ▶ | use Exporter 'import'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | 5 | our @EXPORT = qw(from_nttime to_nttime); | |||||||||||
| 26 | |||||||||||||
| 27 | 5 | my $nttime_factor = 10_000_000; | |||||||||||
| 28 | 5 | my $nttime_offset = 11_644_473_600; | |||||||||||
| 29 | |||||||||||||
| 30 | sub from_nttime ($) { | ||||||||||||
| 31 | 2 | ▶ | my $nttime = shift || return 0; | ||||||||||
|
Subroutine
from_nttime: called CC=2 SCAR=7.2
Pod
documented
Condition50%1/2
shift() || (return 0)
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 32 | |||||||||||||
| 33 | 2 | return $nttime / $nttime_factor - $nttime_offset; | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | sub to_nttime ($) { | ||||||||||||
| 37 | 34 | ▶ | my $time = shift || return 0; | ||||||||||
|
Subroutine
to_nttime: called CC=2 SCAR=7.2
Pod
documented
Condition50%1/2
shift() || (return 0)
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 38 | |||||||||||||
| 39 | 34 | return ($time + $nttime_offset) * $nttime_factor; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 5 | 1; | |||||||||||
| 43 | |||||||||||||
| 44 | __END__ | ||||||||||||