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