Browse Source

Fixes #289

Martin Winkel 11 years ago
parent
commit
2ea0e0ba0c
1 changed files with 7 additions and 4 deletions
  1. 7 4
      library/Zend/Date.php

+ 7 - 4
library/Zend/Date.php

@@ -4514,10 +4514,7 @@ class Zend_Date extends Zend_Date_DateObject
         }
         }
 
 
         if ($precision === null) {
         if ($precision === null) {
-            $precision = strlen($milli);
-            if ($milli < 0) {
-                --$precision;
-            }
+            $precision = $this->_precision;
         }
         }
 
 
         if (!is_int($precision) || $precision < 1 || $precision > 9) {
         if (!is_int($precision) || $precision < 1 || $precision > 9) {
@@ -4525,6 +4522,12 @@ class Zend_Date extends Zend_Date_DateObject
             throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
             throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
         }
         }
 
 
+		if ($this->_precision > $precision) {
+			$milli = $milli * pow(10, $this->_precision - $precision);
+		} elseif ($this->_precision < $precision) {
+			$milli = $milli / pow(10, $precision - $this->_precision);
+		}
+		
         $this->_fractional += $milli;
         $this->_fractional += $milli;
 
 
         // Add/sub milliseconds + add/sub seconds
         // Add/sub milliseconds + add/sub seconds