i created a mock content type below called zippydooda. it contains one custom field called 'dates', defined with From and To components. when i add/edit a content of this type and enter 2009-11-01 in the From or To box, Preview/Save comes back with 2009-10-31. as far as i've checked, the problem shows up only for that date 2009-11-01, and not for 2010-11-01, 2008-11-01, 2009-03-01, 2009-04-01, etc. what could be wrong?

i've tried inspecting the $form_state and it's showing up as 2009-10-31 23:00:00. so as a quick fix (if it can be called that) i just check for that particular timestamp and change it to 2009-11-01 which works fine because date entry granularity does not include time so 11pm on oct 31st 2009 is most likely nov 1st. what might be a better workaround?

Drupal 6.14
MySQL database 5.0.22
PHP 5.1.6
Web server Apache/1.3.29 (Unix) PHP/5.1.6 with Suhosin-Patch mod_ssl/2.8.16 OpenSSL/0.9.7j
Enabled PHP4 module that came with Date

---------------------------------------------------------------------------
$content['type'] = array (
'name' => 'zippydooda',
'type' => 'zippydooda',
'description' => 'test',
'title_label' => 'Title',
'body_label' => 'Body',
'min_word_count' => '0',
'help' => '',
'node_options' =>
array (
'status' => true,
'promote' => true,
'sticky' => false,
'revision' => false,
),
'webfm_attach' => '0',
'old_type' => 'zippydooda',
'orig_type' => '',
'module' => 'node',
'custom' => '1',
'modified' => '1',
'locked' => '0',
'comment' => '0',
'comment_default_mode' => '4',
'comment_default_order' => '1',
'comment_default_per_page' => '50',
'comment_controls' => '3',
'comment_anonymous' => 0,
'comment_subject_field' => '1',
'comment_preview' => '1',
'comment_form_location' => '0',
);
$content['fields'] = array (
0 =>
array (
'label' => 'dates',
'field_name' => 'field_dates',
'type' => 'date',
'widget_type' => 'date_popup',
'change' => 'Change basic information',
'weight' => '31',
'default_value' => 'now',
'default_value2' => 'blank',
'default_value_code' => '',
'default_value_code2' => '',
'input_format' => 'Y-m-d',
'input_format_custom' => '',
'year_range' => '-3:+3',
'increment' => '1',
'advanced' =>
array (
'label_position' => 'above',
'text_parts' =>
array (
'year' => 0,
'month' => 0,
'day' => 0,
'hour' => 0,
'minute' => 0,
'second' => 0,
),
),
'label_position' => 'above',
'text_parts' =>
array (
),
'description' => '',
'group' => false,
'required' => 0,
'multiple' => '0',
'repeat' => 0,
'todate' => 'optional',
'granularity' =>
array (
'year' => 'year',
'month' => 'month',
'day' => 'day',
),
'default_format' => 'field_date_default',
'tz_handling' => 'none',
'timezone_db' => '',
'op' => 'Save field settings',
'module' => 'date',
'widget_module' => 'date',
'columns' =>
array (
'value' =>
array (
'type' => 'varchar',
'length' => 20,
'not null' => false,
'sortable' => true,
'views' => true,
),
'value2' =>
array (
'type' => 'varchar',
'length' => 20,
'not null' => false,
'sortable' => true,
'views' => false,
),
),
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
5 =>
array (
'format' => 'default',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'default',
'exclude' => 0,
),
'full' =>
array (
'format' => 'default',
'exclude' => 0,
),
4 =>
array (
'format' => 'default',
'exclude' => 0,
),
2 =>
array (
'format' => 'default',
'exclude' => 0,
),
3 =>
array (
'format' => 'default',
'exclude' => 0,
),
),
),
);
$content['extra'] = array (
'title' => '-5',
'body_field' => '0',
'revision_information' => '20',
'comment_settings' => '30',
'menu' => '-2',
'book' => '10',
'path' => '30',
'webfm_attachments' => '10',
);

Comments

akeimou’s picture

i'm finding now that the problem is more general and shows up anywhere there's a form element of type date. for example, in a view that has an exposed month filter, the sql condition is showing up as:

AND (DATE_FORMAT(STR_TO_DATE(node_data_field_date.field_date_value, '%Y-%m-%dT%T'), '%Y-%m') = '2009-10')

that is, specifying a filter of november 2009 returns all october 2009 records. that's a very specific month and so i was able to find references to it in date_php4.inc, in particular, the setting of $dstend for North America (case 15). tried disabling the difference between pre- and post-2007. so that for any year,

$dstend = strtotime("last sunday UTC", strtotime("1 november $year UTC"));

and everything seems to work as expected now, as far as i've checked or can see. just a lucky guess because i haven't tried to understand how DST start and end figure in the scheme of things so that workaround may not be a good idea after all. i guess the question then is, if not strtotime("first sunday UTC", strtotime("1 november $year UTC")) what should $dstend be for north america after 2007?

akeimou’s picture

ah i see, this is related to http://drupal.org/node/171527

arlinsandbulte’s picture

This is most likely related to numerous PHP4 bugs (not the module, but PHP4 itself.)
If possible, try upgrading to a current version of PHP 5.2

I'm going to mark this as duplicate of another issue with PHP 4 problems:
#369020: "Every First Saturday" skips Feb, March

arlinsandbulte’s picture

Status: Active » Closed (duplicate)