{
- $fr = $this->rate($from, $when)
+ $fr = $this->rate($from, $when);
+ $tr = $this->rate($to, $when);
+ if ($fr === false) {
+ $fr = 1;
+ }
+ if ($tr === false) {
+ $tr = 1;
+ }
+
//echo '<PRE>';print_R($this->rates);
- $base = (1.0 / $this->rates[$from]) * $val;
+ $base = (1.0 / $fr) * $val;
- return $this->rates[$to] * $base;
+ return $tr * $base;
}