--- /var/www/cbic/modules/date/date/date_elements.inc	2009-10-01 15:38:50.000000000 -0300
+++ /var/www/drupal/sites/all/modules/date/date/date_elements.inc	2010-03-17 12:53:29.000000000 -0300
@@ -506,17 +506,29 @@
       if (isset($form_values[$field_name]['rrule'])) {
         $item['rrule'] = $form_values[$field['field_name']]['rrule'];
       }
-      
+  
       // Test a roundtrip back to the original timezone to catch
       // invalid dates, like 2AM on the day that spring daylight savings
       // time begins in the US.
-      date_timezone_set($from_date, timezone_open($timezone));
-      date_timezone_set($to_date, timezone_open($timezone));
-      if ($test_from != date_format($from_date, 'r')) {
-        $errors[] = t('The From date is invalid.');
-      }
-      if ($test_to != date_format($to_date, 'r')) {
-        $errors[] = t('The To date is invalid.');
+      // This test must only be applied if HOUR in from_date and to_date objects
+      // have been defined by user (granularity includes hour).
+      // Otherwise the hour of from_date and to_date objects should be
+      // ignored to avoid invalidating an hour created automatically by
+      // date_convert function.
+      // Is is important to countries with daylight savings starting at midnight
+      // (like Brazil), where there is no 00:00:00 hour on daylight saving
+      // starting date.
+
+      $granularity = date_format_order($element[$from_field]['#date_format']);
+      if (in_array('hour', $granularity)) {
+        date_timezone_set($from_date, timezone_open($timezone));
+        date_timezone_set($to_date, timezone_open($timezone));
+        if ($test_from != date_format($from_date, 'r')) {
+          $errors[] = t('The From date is invalid.');
+        }
+        if ($test_to != date_format($to_date, 'r')) {
+          $errors[] = t('The To date is invalid.');
+        }
       }
       if (empty($errors)) {
         form_set_value($element, $item, $form_state);
