| 1 | package Finance::GeniusTrader::DateTime::10Min; | ||||||||||||||||||||||||||
| 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::10Min | ||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||
| 16 | This module treat dates describing a 10 minute period. They have the following format : | ||||||||||||||||||||||||||
| 17 | YYYY-MM-DD HH:N0:00 | ||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub map_date_to_time { | ||||||||||||||||||||||||
|
Subroutine
map_date_to_time: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||
| 21 | 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 | ▶ | if ($n >=50) {$n=50} | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 26 | 0 | elsif ($n>=40) {$n=40} | |||||||||||||||||||||||||
| 27 | 0 | elsif ($n>=30) {$n=30} | |||||||||||||||||||||||||
| 28 | 0 | elsif ($n>=20) {$n=20} | |||||||||||||||||||||||||
| 29 | 0 | elsif ($n>=10) {$n=10} | |||||||||||||||||||||||||
| 30 | 0 | else {$n=0} | |||||||||||||||||||||||||
| 31 | 0 | return timelocal(0, $n, $h, $d, $m - 1, $y - 1900); | |||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub map_time_to_date { | ||||||||||||||||||||||||
|
Subroutine
map_time_to_date: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||
| 35 | 0 | my ($time) = @_; | |||||||||||||||||||||||||
| 36 | 0 | my ($sec, $min, $hour, $d, $m, $y, $wd, $yd) = localtime($time); | |||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($min>=50) {$min=50;} | ||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||
| 38 | 0 | elsif ($min>=40) {$min=40;} | |||||||||||||||||||||||||
| 39 | 0 | elsif ($min>=30) {$min=30;} | |||||||||||||||||||||||||
| 40 | 0 | elsif ($min>=20) {$min=20;} | |||||||||||||||||||||||||
| 41 | 0 | elsif ($min>=10) {$min=10;} | |||||||||||||||||||||||||
| 42 | 0 | else {$min=0;} | |||||||||||||||||||||||||
| 43 | 0 | return sprintf("%04d-%02d-%02d %02d:%02d:00", $y + 1900, $m + 1, $d, $hour, $min); | |||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||
| 46 | 1 | 1; | |||||||||||||||||||||||||