Index: duration.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/duration/duration.inc,v
retrieving revision 1.7
diff -u -r1.7 duration.inc
--- duration.inc	26 Oct 2008 14:08:37 -0000	1.7
+++ duration.inc	25 Apr 2010 18:10:20 -0000
@@ -117,11 +117,11 @@
       $this->duration = array(); // to be filled right now
 
       foreach ($this->_allowed_metrics() as $metric) {
-        if (strlen($matches[$metric]) > 0) {
+        if (isset($matches[$metric]) && strlen($matches[$metric]) > 0) {
           $this->duration[$metric] = floatval($matches[$metric]);
         }
       }
-      if (strlen($this->duration['daysonly']) > 0) {
+      if (isset($this->duration['daysonly']) && strlen($this->duration['daysonly']) > 0) {
         $this->duration['days'] = $this->duration['daysonly'];
         $this->duration['weeks'] = 0; // 'Tyyyy-ddd(...)' indicates a y/w/d format
         unset($this->duration['daysonly']);
@@ -134,6 +134,14 @@
   }
 
   /**
+   * Automatic conversion into a string.
+   */
+
+  function __toString() {
+    return $this->to_iso();
+  }
+
+  /**
    * Determine if this duration object is valid, i.e. the ISO 8601 string was
    * successfully be parsed and further calculations can be done.
    * If this method returns FALSE, the behaviour and result of any other
