line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UID2::Client::Timestamp; |
2
|
5
|
|
|
5
|
|
55506
|
use strict; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
110
|
|
3
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
106
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
2151
|
use Time::HiRes qw(gettimeofday); |
|
5
|
|
|
|
|
5372
|
|
|
5
|
|
|
|
|
17
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub now { |
8
|
174
|
|
|
174
|
1
|
6382
|
my $class = shift; |
9
|
174
|
|
|
|
|
551
|
$class->from_epoch_milli(int(gettimeofday() * 1000)); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub from_epoch_second { |
13
|
5
|
|
|
5
|
1
|
41
|
my ($class, $epoch_second) = @_; |
14
|
5
|
|
|
|
|
14
|
$class->from_epoch_milli($epoch_second * 1000); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub from_epoch_milli { |
18
|
315
|
|
|
315
|
1
|
478
|
my ($class, $epoch_milli) = @_; |
19
|
315
|
|
|
|
|
942
|
bless \$epoch_milli, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub get_epoch_second { |
23
|
204
|
|
|
204
|
1
|
1763
|
my $self = shift; |
24
|
204
|
|
|
|
|
587
|
int($$self / 1000); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_epoch_milli { |
28
|
177
|
|
|
177
|
1
|
1940
|
my $self = shift; |
29
|
177
|
|
|
|
|
602
|
$$self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub is_zero { |
33
|
2
|
|
|
2
|
1
|
751
|
my $self = shift; |
34
|
2
|
|
|
|
|
7
|
$$self == 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub add_seconds { |
38
|
108
|
|
|
108
|
1
|
2727
|
my ($self, $seconds) = @_; |
39
|
108
|
|
|
|
|
218
|
ref($self)->from_epoch_milli($$self + ($seconds * 1000)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub add_days { |
43
|
58
|
|
|
58
|
1
|
15805
|
my ($self, $days) = @_; |
44
|
58
|
|
|
|
|
98
|
$self->add_seconds($days * 24 * 60 * 60); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |