line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mango::BSON::Time; |
2
|
11
|
|
|
11
|
|
33
|
use Mojo::Base -base; |
|
11
|
|
|
|
|
12
|
|
|
11
|
|
|
|
|
53
|
|
3
|
11
|
|
|
11
|
|
1430
|
use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1; |
|
11
|
|
|
7
|
|
23
|
|
|
11
|
|
|
0
|
|
70
|
|
|
0
|
|
|
|
|
0
|
|
|
7
|
|
|
|
|
274
|
|
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
4736
|
use Mojo::Date; |
|
11
|
|
|
|
|
25928
|
|
|
11
|
|
|
|
|
79
|
|
6
|
11
|
|
|
11
|
|
280
|
use Time::HiRes 'time'; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
56
|
|
7
|
|
|
|
|
|
|
|
8
|
12
|
|
66
|
12
|
1
|
62
|
sub new { shift->SUPER::new(time => shift // int(time * 1000)) } |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
1
|
70
|
sub TO_JSON { 0 + shift->{time} } |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
1
|
8
|
sub to_datetime { Mojo::Date->new(shift->to_epoch)->to_datetime } |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
1
|
21
|
sub to_epoch { shift->to_string / 1000 } |
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
11
|
1
|
121
|
sub to_string { shift->{time} } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
1; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=encoding utf8 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Mango::BSON::Time - Datetime type |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Mango::BSON::Time; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $time = Mango::BSON::Time->new(time * 1000); |
31
|
|
|
|
|
|
|
say $time->to_epoch; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
L is a container for the BSON datetime type used by |
36
|
|
|
|
|
|
|
L. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
L inherits all methods from L and implements |
41
|
|
|
|
|
|
|
the following new ones. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $time = Mango::BSON::Time->new; |
46
|
|
|
|
|
|
|
my $time = Mango::BSON::Time->new(time * 1000); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Construct a new L object. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 TO_JSON |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $num = $time->TO_JSON; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Numeric representation of time. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 to_datetime |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $str = $time->to_datetime; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Convert time to L date and time. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 to_epoch |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $epoch = $time->to_epoch; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Convert time to floating seconds since the epoch. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 to_string |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $str = $time->to_string; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Stringify time. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 OPERATORS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L overloads the following operators. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 bool |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $bool = !!$time; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Always true. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 stringify |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $str = "$time"; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Alias for L. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L, L, L. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |