I noticed this bug when trying to debug an issue in the token module (http://drupal.org/node/114610) where date_make_date() is called with only a $value argument. Looking at the code of date.inc, it seems that the problem lies in date_set_date(). At line 347, there is the following logic:

 elseif (!$error && $type == 'db' && $date->local->iso && (!$date->local->iso || $reset)) 
  if (!date_no_conversion($date)) {
      // compute local value if the db value was submitted
      // and the local value has not been created and there is a local timezone
      date_convert_timezone($date, 'GMT', $date->local->timezone, 'local');
    }
    else {
      $date->local = $date->db;
    }

For a new date $date->local->iso will not be set. So neither $date->local nor $date->db will be set. Note that this contrasts with the logic when the $type='local':

 if (!$error && $type == 'local' && (!$date->db->iso || $reset))

In the attached patch, I convert the logic for $type='db' to be the mirror image of the logic for $type='local'.
But maybe I'm missing something subtle!

CommentFileSizeAuthor
date_set_date.patch725 bytesegfrith

Comments

karens’s picture

Status: Needs review » Fixed

This function is gone in 5.2 and all the code has been completely re-worked to use the PHP 5.2 methods to create and alter dates.

karens’s picture

Status: Fixed » Closed (won't fix)

I guess won't fix is more accurate -- won't apply this patch but the underlying problem is fixed.