line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Exchange::Time; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mail::Exchange::Time - time object to convert between unix time and MS time |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Mail::Exchange::Time; |
10
|
|
|
|
|
|
|
my $now=Mail::Exchange::Time->new($unixtime); |
11
|
|
|
|
|
|
|
my $now=Mail::Exchange::Time->from_mstime($mstime); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
print $now->unixtime; |
14
|
|
|
|
|
|
|
print $now->mstime; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Mail::Exchange::Time qw(mstime_to_unixtime unixtime_to_mstime); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
print mstime_to_unixtime($mstime); |
20
|
|
|
|
|
|
|
print unixtime_to_mstime($unixtime); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
A Mail::Exchange::Time object allows you to convert between unix time |
25
|
|
|
|
|
|
|
and the time used internally in by Microsoft, which is defined as number |
26
|
|
|
|
|
|
|
of 100-nsec-intervals since Jan 01, 1901. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
6
|
|
28413
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
219
|
|
31
|
6
|
|
|
6
|
|
36
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
195
|
|
32
|
6
|
|
|
6
|
|
154
|
use 5.008; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
211
|
|
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
6
|
|
34
|
use Exporter; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
321
|
|
35
|
6
|
|
|
6
|
|
34
|
use vars qw ($VERSION @ISA @EXPORT_OK); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
2105
|
|
36
|
|
|
|
|
|
|
@ISA=qw(Exporter); |
37
|
|
|
|
|
|
|
@EXPORT_OK=qw(mstime_to_unixtime unixtime_to_mstime); |
38
|
|
|
|
|
|
|
$VERSION=0.03; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 new() |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$now=Mail::Exchange::Time->new(time()) |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Creates a time object from unix time. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
50
|
1
|
|
|
1
|
1
|
4
|
my $class=shift; |
51
|
1
|
|
|
|
|
2
|
my $time=shift; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
4
|
my $self={ |
54
|
|
|
|
|
|
|
unixtime => $time, |
55
|
|
|
|
|
|
|
mstime => unixtime_to_mstime($time), |
56
|
|
|
|
|
|
|
}; |
57
|
1
|
|
|
|
|
4
|
bless $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 from_mstime() |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$now=Mail::Exchange::Time->from_mstime(129918359788540682) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Creates a time object from unix time. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub from_mstime { |
69
|
1
|
|
|
1
|
1
|
2
|
my $class=shift; |
70
|
1
|
|
|
|
|
2
|
my $time=shift; |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
3
|
my $self={ |
73
|
|
|
|
|
|
|
mstime => $time, |
74
|
|
|
|
|
|
|
unixtime => mstime_to_unixtime($time), |
75
|
|
|
|
|
|
|
}; |
76
|
1
|
|
|
|
|
4
|
bless $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 unixtime() |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$unixtime=$now->unixtime() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns the unix time from a time object. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
2
|
1
|
1014
|
sub unixtime () { my $self=shift; return $self->{unixtime}; } |
|
2
|
|
|
|
|
13
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 mstime() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$mstime=$now->mstime() |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns the Microsoft time from a time object. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
2
|
1
|
3
|
sub mstime () { my $self=shift; return $self->{mstime}; } |
|
2
|
|
|
|
|
9
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 mstime_to_unixtime() |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
use Mail::Exchange::Time qw(mstime_to_unixtime) |
102
|
|
|
|
|
|
|
$unixtime=mstime_to_unixtime(129918359788540682) |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Converts a microsoft time to unix format. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub mstime_to_unixtime { |
109
|
2
|
|
|
2
|
1
|
667
|
my $mstime=shift; |
110
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
13
|
return ($mstime - 116_444_736_000_000_000)/10_000_000; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 unixtime_to_mstime() |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use Mail::Exchange::Time qw(unixtime_to_mstime) |
117
|
|
|
|
|
|
|
$mstime=unixtime_to_mstime(time()) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Converts a unix time to microsoft format. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub unixtime_to_mstime{ |
124
|
2
|
|
|
2
|
1
|
6
|
my $unixtime=shift; |
125
|
|
|
|
|
|
|
|
126
|
2
|
|
|
|
|
10
|
return $unixtime * 10_000_000 + 116_444_736_000_000_000; |
127
|
|
|
|
|
|
|
} |