line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::GeniusTrader::DateTime::Tick; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright 2000-2002 Raphaël Hertzog, Fabien Fulhaber |
4
|
|
|
|
|
|
|
# Copyright 2005 João Antunes Costa |
5
|
|
|
|
|
|
|
# This file is distributed under the terms of the General Public License |
6
|
|
|
|
|
|
|
# version 2 or (at your option) any later version. |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
9
|
1
|
|
|
1
|
|
5
|
use vars qw(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Finance::GeniusTrader::DateTime; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
229
|
|
12
|
1
|
|
|
1
|
|
5855
|
use Time::Local; |
|
1
|
|
|
|
|
2243
|
|
|
1
|
|
|
|
|
319
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 Finance::GeniusTrader::DateTime::Tick |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module treat dates describing ticks. They have the following format : |
17
|
|
|
|
|
|
|
YYYY-MM-DD HH:NN:SS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
sub map_date_to_time { |
21
|
0
|
|
|
0
|
0
|
|
my ($value) = @_; |
22
|
0
|
|
|
|
|
|
my ($date, $time) = split / /, $value; |
23
|
0
|
0
|
|
|
|
|
$time = '00:00:00' unless (defined($time)); |
24
|
0
|
|
|
|
|
|
my ($y, $m, $d) = split /-/, $date; |
25
|
0
|
|
|
|
|
|
my ($h, $n, $s) = split /:/, $time; |
26
|
0
|
|
|
|
|
|
return timelocal($s, $n, $h, $d, $m - 1, $y - 1900); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub map_time_to_date { |
30
|
0
|
|
|
0
|
0
|
|
my ($time) = @_; |
31
|
0
|
|
|
|
|
|
my ($sec, $min, $hour, $d, $m, $y, $wd, $yd) = localtime($time); |
32
|
0
|
|
|
|
|
|
return sprintf("%04d-%02d-%02d %02d:%02d:%02d", $y + 1900, $m + 1, $d, $hour, $min, $sec); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |