GeniusTrader/DateTime/Year.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
map_date_to_time
2.0
map_time_to_date
2.0
timeframe_ratio
2.0
CRAP 2.0
1 package Finance::GeniusTrader::DateTime::Year;
2  
3 # Copyright 2000-2002 Raphaƫl Hertzog, Fabien Fulhaber
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6  
7 use strict;
8 use vars qw();
9  
10 use Finance::GeniusTrader::DateTime;
11 #ALL# use Log::Log4perl qw(:easy);
12 use Time::Local;
13  
14 =head1 Finance::GeniusTrader::DateTime::Year
15  
16 This module treat dates describing a year. They have the following format :
17 YYYY
18  
19 =cut
20 sub map_date_to_time {
21 my ($date) = @_;
22 my ($y) = split /-/, $date;
23 return timelocal(0, 0, 0, 1, 0, $y - 1900);
24 }
25  
26 sub map_time_to_date {
27 my ($time) = @_;
28 my ($sec, $min, $hour, $d, $m, $y, $wd, $yd) = localtime($time);
29 return sprintf("%04d", $y + 1900);
30 }
31  
32 sub timeframe_ratio {
33 my ($tf) = @_;
34  
35 #WAR# WARN "timeframe must be smaller than a year" unless ($tf < $YEAR);
36  
37 $tf == $MONTH && return 12;
38 $tf == $WEEK && return 52;
39 $tf == $DAY && return 250;
40 return Finance::GeniusTrader::DateTime::timeframe_ratio($DAY, $tf) * 250;
41 }
42  
43 1;