I have an all day event (shared calendar date field across multiple content types: can have end dates, be flagged as all day and recurring) on Monday, 1 Sep 2014 which does not display. If I change the date for the event to all day Tuesday, 2 Sep 2014 it displays fine. If I change the date from all day to start at 07:00 it also displays on Monday, 1 Sep 2014. This infers that the display of the date is affected by the all day flag only on the first day of the month - possibly because the first day in this case is a Monday in the first column???

Comments

JayDarnell’s picture

I am also having this issue. It happens regardless of whether or not the event is repeating or what month I use.

jazztini’s picture

Same here. Anything on the first day of the month, all day or otherwise, doesn't show on the month view. It shows on the week or day view just fine.

UPDATE: setting timezone handling to "No time zone conversion" in my Field Settings for the date field causes the event to appear. I'm using a field type of Date (ISO format).

foagth’s picture

I had the same problem with a custom content type of mine.
Date is stored in Unix timestamp format and all my nodes on first day of any month didn't display.
I used hook_views_query_alter to fix this:

<?php
 function your_module_views_query_alter(&$view, &$query) {
  if ($view->name == "your_calendar_monthly_view" )
  {     
      // change the from date format to YYY-MM-DD
      $view->query->where['date']['conditions'][0]['field'] = "TO_CHAR(field_data_your_datefield.your_datefield_value::ABSTIME, 'YYYY-MM-DD') >= :node_date_argument AND TO_CHAR(field_data_your_datefield.your_datefield_value::ABSTIME, 'YYYY-MM') <= :node_date_argument1";
	  
	  // take the date that the calendar passes
	  $given_date = $view->query->where['date']['conditions'][0]['value'][':node_date_argument'];	
      // and subtract one day	  
	  $new_date =(date('Y-m-d',  strToTime($given_date.' this year -1 day')));	  
	  $view->query->where['date']['conditions'][0]['value'][':node_date_argument'] = $new_date;	 
  }
}
?>

'your_datefield' should be replaced with your date field :)
use dpm to confirm the query fields changed.

Moreover, I had to change the Link format in the pager settings to clean urls in order to have the same result when clicking the next months

doppel’s picture

I have the same problem.
tried the code above and got error.

<?php
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '::ABSTIME, 'YYYY-MM-DD') >= '2014-09-30' AND TO_CHAR(field_data_field_holiday_da' at line 2
?>
doppel’s picture

This code works for me. =)

<?php
function your_module_query_alter(&$view, &$query) {
  if ($view->name == "your_view" )
  {
      // change the from date format to YYY-MM-DD
      $view->query->where['date']['conditions'][0]['field'] = "DATE_FORMAT(FROM_UNIXTIME(field_data_your_field.your_field_value), '%Y-%m-%d') >= :node_date_argument AND DATE_FORMAT(FROM_UNIXTIME(field_data_your_field.your_field_value), '%Y-%m') <= :node_date_argument1";
      // take the date that the calendar passes
      $given_date = $view->query->where['date']['conditions'][0]['value'][':node_date_argument'];
      // and subtract one day
      $new_date =(date('Y-m-d',  strToTime($given_date.' this year -1 day')));
      $view->query->where['date']['conditions'][0]['value'][':node_date_argument'] = $new_date;
  }
}

?>
Kasey_MK’s picture

Neither of these solutions worked for me (I did try changing your_module_query_alter to your_module_views_query_alter in #5).

Kasey_MK’s picture

After lots of experimentation, I discovered that if I un-checked "all day" and entered 11:59pm as the end time, and changed the date's timezone to match the site's timezone, the event would show correctly as an all-day event on the first of the month (and this same adjustment did not break events that were already showing as all-day events on other days of the month).

I wrote a hook_node_presave function to rewrite event dates (where the start datetime and end datetime match each other) as follows: start times to 00:00:00, end times to 23:59:59, and timezone and offsets to match the site's. Multi-day all-day events already appear as expected, so I do not alter those.

/**
 * Implementation of hook_node_presave.
 * All-day (one-day) events need to start at 00:00:00 and end at 23:59:59 in the site's time zone.
 */
function MODULENAME_node_presave($node) {
  // Check to see if the date field has a timezone set.
  if (isset($node->DATEFIELDNAME['und'][0]['timezone'])) {
    // Grab the start and end dates
    $startDate = $node->DATEFIELDNAME['und'][0]['value'];
    $endDate = $node->DATEFIELDNAME['und'][0]['value2'];
    // If the start and end dates are the same...
    if ($startDate == $endDate) {
      // Create a timezone object for the site's time zone
      $timezoneSite = new DateTimeZone($node->DATEFIELDNAME['und'][0]['timezone_db']);
      // Calculate the GMT/UTC offset for $timezoneSite
      $tzOffset = new DateTime('now', $timezoneSite);
      $timezoneOffset = $timezoneSite->getOffset($tzOffset);
      // Rewrite the start time as midnight and the end time as 11:59
      $node->DATEFIELDNAME['und'][0]['value'] = substr_replace($startDate, "00:00:00", -8);
      $node->DATEFIELDNAME['und'][0]['value2'] = substr_replace($endDate, "23:59:59", -8);
      // Change the timezone and offsets to match the site's
      $node->DATEFIELDNAME['und'][0]['timezone'] = $node->DATEFIELDNAME['und'][0]['timezone_db'];
      $node->DATEFIELDNAME['und'][0]['offset'] = $timezoneOffset;
      $node->DATEFIELDNAME['und'][0]['offset2'] = $timezoneOffset;
    }
  }
}

I did not have to change the granularity of my date field (minute), though I did change the increment (to 1 minute from 15 minutes). The latter change didn't affect the value stored in the database, but it was confusing to open the node and see 12:00am on the following day for the event end time (the closest 15-minute increment) instead of 11:59pm on the event's last day.

Our site does not allow users to set their own timezone, so I haven't tested for that possibility. This solution allows us to keep our site's timezone (instead of setting it to UTC), as well as the date's timezone (so we can display events across multiple regions).

Michael_Lessard_micles.biz’s picture

From what I can tell on my set-up :

a) Overall site settings : local timezone (GTM-5) ;

b) Date Field (in my event node type) set to not do any timezone conversions ;

c) Monthly Calendar Views is evidently set to GMT-0, so some events at the beginning and end of the month can get flushed over to the wrong month.

If I am correct. this means it is something that needs to be fixed in the Calendar View or module as such.

EDIT: Turns out I needed to set my Date Fields to my same site timezone initially.
So I just did: set event Date Field to "same as site" and it fixed it.

( but maybe the installation Read Me text or documentation should explain about the timezone misconfigurations.)

merrizervas’s picture

Issue summary: View changes
izmeez’s picture

apaderno’s picture

Version: 7.x-3.4 » 7.x-3.x-dev
Neslee Canil Pinto’s picture

Status: Active » Closed (outdated)