| 1 | package Finance::GeniusTrader::DateTime::2Hour; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use vars qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Finance::GeniusTrader::DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Time::Local; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 Finance::GeniusTrader::DateTime::2Hour | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | This module treat dates describing the 2Hour timeframe. They have the following format : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | YYYY-MM-DD HH:00:00 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub map_date_to_time { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_date_to_time: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my ($date, $time) = split / /, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my ($y, $m, $d) = split /-/, $date; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $time = "00:00:00" if (!defined($time)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my ($h, , ) = split /:/, $time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ($h >=22) {$h=22} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | elsif ($h>=20) {$h=20} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | elsif ($h>=18) {$h=18} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | elsif ($h>=16) {$h=16} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | elsif ($h>=14) {$h=14} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | elsif ($h>=12) {$h=12} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | elsif ($h>=10) {$h=10} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | elsif ($h>=8) {$h=8} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | elsif ($h>=6) {$h=6} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | elsif ($h>=4) {$h=4} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | elsif ($h>=2) {$h=2} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | else {$h=0} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return timelocal(0, 0, $h, $d, $m - 1, $y - 1900); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub map_time_to_date { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_time_to_date: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my ($time) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my ($sec, $min, $h, $d, $m, $y, $wd, $yd) = localtime($time); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ($h >=22) {$h=22} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | elsif ($h>=20) {$h=20} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | elsif ($h>=18) {$h=18} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | elsif ($h>=16) {$h=16} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | elsif ($h>=14) {$h=14} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | elsif ($h>=12) {$h=12} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | elsif ($h>=10) {$h=10} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | elsif ($h>=8) {$h=8} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | elsif ($h>=6) {$h=6} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | elsif ($h>=4) {$h=4} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | elsif ($h>=2) {$h=2} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | else {$h=0} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return sprintf("%04d-%02d-%02d %02d:00:00", $y + 1900, $m + 1, $d, $h); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||