Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1082 diff -u -r1.1082 node.module --- modules/node/node.module 10 Jul 2009 05:58:13 -0000 1.1082 +++ modules/node/node.module 15 Jul 2009 03:08:11 -0000 @@ -879,11 +879,6 @@ // are dealing with an anonymous user we set the user ID to 0. form_set_error('name', t('The username %name does not exist.', array('%name' => $node->name))); } - - // Validate the "authored on" field. - if (!empty($node->date) && strtotime($node->date) === FALSE) { - form_set_error('date', t('You have to specify a valid date.')); - } } // Do node-type-specific validation checks. @@ -909,7 +904,6 @@ $node->uid = 0; } } - $node->created = !empty($node->date) ? strtotime($node->date) : REQUEST_TIME; $node->validated = TRUE; return $node; Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.70 diff -u -r1.70 node.pages.inc --- modules/node/node.pages.inc 22 Jun 2009 09:10:05 -0000 1.70 +++ modules/node/node.pages.inc 15 Jul 2009 03:08:11 -0000 @@ -206,17 +206,13 @@ '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))), ); - $form['author']['date'] = array( - '#type' => 'textfield', + $form['author']['created'] = array( + '#type' => 'datetime', '#title' => t('Authored on'), - '#maxlength' => 25, '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the timezone offset from UTC. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'Y-m-d H:i:s O'), '%timezone' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'O'))), + '#default_value' => isset($node->created) ? $node->created : '', ); - if (isset($node->date)) { - $form['author']['date']['#default_value'] = $node->date; - } - // Node options for administrators $form['options'] = array( '#type' => 'fieldset', Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.350 diff -u -r1.350 form.inc --- includes/form.inc 14 Jul 2009 10:22:15 -0000 1.350 +++ includes/form.inc 15 Jul 2009 03:08:11 -0000 @@ -1305,6 +1305,33 @@ } /** + * Helper function to determine the value for a datetime form element. + * + * @param $form + * The form element whose value is being populated. +* @param $input + * The incoming input to populate the form element. If this is FALSE, + * the element's default value should be returned. + * @return + * The data that will appear in the $element_state['values'] collection + * for this element. Return nothing to use the default. + */ +function form_type_datetime_value($element, $input = FALSE) { + if ($input !== FALSE) { + if (is_array($input) && isset($input['datetime'])) { + $time = strtotime($input['datetime']); + return $time !== FALSE ? $time : REQUEST_TIME; + } + else { + return REQUEST_TIME; + } + } + else { + return format_date($element['#default_value'], 'custom', 'Y-m-d H:i:s O'); + } +} + +/** * Helper function to determine the value for a password_confirm form * element. * @@ -1754,6 +1781,27 @@ } /** + * Roll out a single date/time element. + */ +function form_process_datetime($element) { + // Default to current date. + if (empty($element['#value'])) { + $element['#value'] = REQUEST_TIME; + } + $element['#tree'] = TRUE; + + // Display the textfield for the date/time input. + $element['datetime'] = array( + '#type' => 'textfield', + '#value' => $element['#value'], + '#attributes' => $element['#attributes'], + '#maxlength' => 25, + ); + + return $element; +} + +/** * Validates the date type to stop dates like February 30, 2006. */ function date_validate($form) { @@ -1763,6 +1811,15 @@ } /** + * Validates a date/time element to make sure it has a valid date and time. + */ +function datetime_validate($form) { + if (!empty($form['#value']) && strtotime($form['#value']) === FALSE) { + form_error($form, t('You have to specify a valid date and time.')); + } +} + +/** * Helper function for usage with drupal_map_assoc to display month names. */ function map_month($month) { Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.722 diff -u -r1.722 system.module --- modules/system/system.module 5 Jul 2009 18:00:10 -0000 1.722 +++ modules/system/system.module 15 Jul 2009 03:08:11 -0000 @@ -395,6 +395,14 @@ '#theme_wrapper' => 'form_element', ); + $type['datetime'] = array( + '#input' => TRUE, + '#element_validate' => array('datetime_validate'), + '#process' => array('form_process_datetime'), + '#theme' => 'date', + '#theme_wrapper' => 'form_element', + ); + $type['file'] = array( '#input' => TRUE, '#size' => 60,