File: MockTime.pm

package info (click to toggle)
libhttp-cookiejar-perl 0.008-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 264 kB
  • sloc: perl: 430; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 315 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use strict;
use warnings;

package MockTime;

my ( $_original_time, $_offset );

sub time () {
    return $_original_time + $_offset;
}

sub offset {
    my ( $class, $offset ) = @_;
    $_offset = $offset;
}

BEGIN {
    ( $_original_time, $_offset ) = ( CORE::time(), 0 );
    *CORE::GLOBAL::time = \&time;
}

1;