« blib/lib/Language/Farnsworth/Value/String.pm
↑ Summary
blib/lib/Language/Farnsworth/Dimension.pm »
| 1 | package Language::Farnsworth::Value::Date; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Language::Farnsworth::Dimension; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use base 'Language::Farnsworth::Value'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | require Language::Farnsworth::Value::Pari; | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Language::Farnsworth::Error; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | { #slight inefficiency here, but it fixes the circular reference issue | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | my $time; | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | sub TYPE_TIME {return $time if $time; $time=new Language::Farnsworth::Value::Pari(0, {time=>1})} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TYPE_TIME: called CC=2 SCAR=7.2
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #use DateTime::Format::DateManip; | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #use Date::Manip; | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use DateTimeX::Easy; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | our $VERSION = 0.6; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | use overload | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | '+' => \&add, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | '-' => \&subtract, | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | '*' => \&mult, | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | '/' => \&div, | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | '%' => \&mod, | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | '**' => \&pow, | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | '<=>' => \&compare, | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | 'bool' => \&bool; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | ▶ | use base qw(Language::Farnsworth::Value); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | #this is the REQUIRED fields for Language::Farnsworth::Value subclasses | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | #dimen => a Language::Farnsworth::Dimension object | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | #this is so i can make a -> conforms in Language::Farnsworth::Value, to replace the existing code, i'm also planning on adding some definitions such as, TYPE_PARI, TYPE_STRING, TYPE_LAMBDA, TYPE_DATE, etc. to make certain things easier | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | my $outmagic = shift; #i'm still not sure on this one | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 7 | ▶ | error "Non string or date given as \$value to constructor" unless (ref($value) eq "" || ref($value) eq "DateTime") && defined($value); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $value eq "" || ref $value eq "DateTime" and defined $value
ref $value eq "" or ref $value eq "DateTime"
MC/DC0%0/3
ref $value eq "" || ref $value eq "DateTime" and defined $value
ref $value eq ""
ref $value eq "DateTime"
defined $value
Truth table20%1/5
A or B and C
A= ref $value eq ""B= ref $value eq "DateTime"C= defined $value
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 7 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 7 | $self->{outmagic} = $outmagic; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 7 | ▶ | if (ref($value) ne "DateTime") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 7 | my $dt = DateTimeX::Easy->parse($value); | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 7 | ▶ | error "failed to parse date!" unless defined $dt; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 7 | my $tz = $dt->time_zone(); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 7 | ▶ | if ($tz->is_floating()) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 7 | $dt->set_time_zone('UTC'); #force it to UTC | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 7 | $self->{date} = $dt; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->{date} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub getdate | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getdate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | return $_[0]->{date}; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | sub type | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return "Date"; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ####### | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | #The rest of this code can be GREATLY cleaned up by assuming that $one is of type, Language::Farnsworth::Value::Pari, this means that i can slowly redo a lot of this code | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | sub add | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=6 SCAR=26.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | error "Non reference given to addition of Date" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | #if we're not being added to a Language::Farnsworth::Value::Pari, the higher class object needs to handle it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | if ($two->isa("Language::Farnsworth::Value::Pari")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | if ($two->conforms(TYPE_TIME())) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return new Language::Farnsworth::Value::Date($one->getdate()->clone()->add(seconds => "".$two->getpari())); | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | error "Scalar value given to addition of date"; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | return $two->add($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (!$two->istype("Date")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | error "Given non date to date operation"; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | error "Adding dates does nothing useful."; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | sub subtract | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subtract: called CC=10 SCAR=31.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | error "Non reference given to addition of dates" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | #if we're not being added to a Language::Farnsworth::Value::Pari, the higher class object needs to handle it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | if ($two->isa("Language::Farnsworth::Value::Pari")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ($two->conforms(TYPE_TIME())) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (!$rev) #we're first! | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return new Language::Farnsworth::Value::Date($one->getdate()->clone()->add(seconds => "".(-$two->getpari()))); | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | error "And just now what is that supposed to do? a negative date? what the hell is that?"; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | error "Scalar value given to addition to string" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | return $two->subtract($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | if (!$two->istype("Date")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | error "Given non date to date operation"; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | my $diff; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | $diff = $one->getdate()->subtract_datetime_absolute($two->getdate()) unless $rev; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | $diff = $two->getdate()->subtract_datetime_absolute($one->getdate()) if $rev; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | my ($secs, $nano) = $diff->in_units('seconds','nanoseconds'); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | my $rdiff = $secs + 0.000000001 *$nano; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | my $ret = Language::Farnsworth::Value::Pari->new($rdiff, {time => 1}); | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | sub modulus | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modulus: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | error "Non reference given to modulus of date" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | error "Scalar value given to modulus of date" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return $two->mod($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (!$two->istype("Date")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | error "Given non date to date operation"; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | error "Modulusing dates? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub mult | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mult: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | error "Non reference given to multiplication of dates" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | error "Scalar value given to multiplcation of dates" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return $two->mult($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if (!$two->istype("Date")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | error "Given non date to date operation"; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | error "Multiplying dates? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | sub div | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
div: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | error "Non reference given to division" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | error "Scalar value given to division to date" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return $two->div($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if (!$two->istype("Date")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | error "Given non date to dates operation"; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | error "Dividing dates? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | sub bool | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bool: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | #seems good enough of an idea to me | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | #i have a bug HERE | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | #print "BOOLCONV\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | #print Dumper($self); | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | #print "ENDBOOLCONV\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return 1; #what else should it be? | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | sub pow | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pow: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | error "Non reference given to exponentiation of dates" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | error "Exponentiating dates? what did you think this would do, create a black hole?" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return $two->pow($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if (!$two->istype("Date")) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | error "Given non date to date operation"; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | error "Exponentiating dates? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub compare | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | error "Non reference given to compare of dates" unless ref($two); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | #if we're not being added to a Language::Farnsworth::Value::Pari, the higher class object needs to handle it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | error "Scalar value given to division of dates" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return $two->compare($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $rv = $rev ? -1 : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | #check for $two being a simple value | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $tv = $two->getdate(); | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $ov = $one->getdate(); | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | #i also need to check the units, but that will come later | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | #NOTE TO SELF this needs to be more helpful, i'll probably do something by adding stuff in ->new to be able to fetch more about the processing | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | error "Unable to process different types in compare of dates\n" unless $one->conforms($two); #always call this on one, since $two COULD be some other object | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | #moving this down so that i don't do any math i don't have to | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $new = $ov <=> $tv; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | return $new * $rv; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||