line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::GeniusTrader::DateTime::3Hour; |
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
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
5
|
use vars qw(); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
18
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Finance::GeniusTrader::DateTime; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
203
|
|
12
|
1
|
|
|
1
|
|
6
|
use Time::Local; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
803
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 Finance::GeniusTrader::DateTime::3Hour |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module treat dates describing the 3Hour timeframe. They have the following format : |
17
|
|
|
|
|
|
|
YYYY-MM-DD HH:00:00 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
sub map_date_to_time { |
21
|
0
|
|
|
0
|
0
|
|
my ($value) = @_; |
22
|
0
|
|
|
|
|
|
my ($date, $time) = split / /, $value; |
23
|
0
|
|
|
|
|
|
my ($y, $m, $d) = split /-/, $date; |
24
|
0
|
0
|
|
|
|
|
$time = "00:00:00" if (!defined($time)); |
25
|
0
|
|
|
|
|
|
my ($h, , ) = split /:/, $time; |
26
|
0
|
0
|
|
|
|
|
if ($h >=21) {$h=21} |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
elsif ($h>=18) {$h=18} |
28
|
0
|
|
|
|
|
|
elsif ($h>=15) {$h=15} |
29
|
0
|
|
|
|
|
|
elsif ($h>=12) {$h=12} |
30
|
0
|
|
|
|
|
|
elsif ($h>=9) {$h=9} |
31
|
0
|
|
|
|
|
|
elsif ($h>=6) {$h=6} |
32
|
0
|
|
|
|
|
|
elsif ($h>=3) {$h=3} |
33
|
|
|
|
|
|
|
else {$h=0} |
34
|
0
|
|
|
|
|
|
return timelocal(0, 0, $h, $d, $m - 1, $y - 1900); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub map_time_to_date { |
38
|
0
|
|
|
0
|
0
|
|
my ($time) = @_; |
39
|
0
|
|
|
|
|
|
my ($sec, $min, $hour, $d, $m, $y, $wd, $yd) = localtime($time); |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ($hour>=21) {$hour=21;} |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
elsif ($hour>=18) {$hour=18;} |
43
|
0
|
|
|
|
|
|
elsif ($hour>=15) {$hour=15;} |
44
|
0
|
|
|
|
|
|
elsif ($hour>=12) {$hour=12;} |
45
|
0
|
|
|
|
|
|
elsif ($hour>=9) {$hour=9;} |
46
|
0
|
|
|
|
|
|
elsif ($hour>=6) {$hour=6;} |
47
|
0
|
|
|
|
|
|
elsif ($hour>=3) {$hour=3;} |
48
|
|
|
|
|
|
|
else {$hour=0;} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return sprintf("%04d-%02d-%02d %02d:00:00", $y + 1900, $m + 1, $d, $hour); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |