The end date is being overridden when the date is being provided by another field or a token.

Line 105 in addtocalendar.build.inc will always override the end date regardless of whether it has already been set or not.

if (empty($end_date)) {
          $build['addtocalendar'][$index]['atc_date_end']['#value'] = (!empty($build['addtocalendar'][$index]['atc_date_end']['#value'])) ? $build['addtocalendar'][$index]['atc_date_end']['#value'] : $build['addtocalendar'][$index]['atc_date_start']['#value'];
          $build['addtocalendar'][$index]['atc_date_end']['#value'] = (!empty($build['addtocalendar'][$index]['atc_date_end']['#value'])) ? $build['addtocalendar'][$index]['atc_date_start']['#value'] : $date->format('Y-m-d H:i:s', ['timezone' => $timeZone]);
        }

Comments

ls206 created an issue. See original summary.

sawtell’s picture

StatusFileSize
new1.03 KB

Patch added

geovanni.conti’s picture

Status: Active » Needs review

Hi.

I get into the same problem and same solution that you.

Your patch worked for me, thanks

faline’s picture

Status: Needs review » Reviewed & tested by the community

We tested this in our project and the patch works fine for us.

Thanks!

gg24’s picture

Assigned: Unassigned » gg24

  • gg24 committed 521bc48 on 8.x-2.x authored by ls206
    Issue #2894914 by ls206, geovanni.conti, faline, gg24: End date...
gg24’s picture

Assigned: gg24 » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks everyone for the efforts.

gg24’s picture

Assigned: Unassigned » gg24
Status: Fixed » Active

Opening this back as it messed up with timezone.

gg24’s picture

Assigned: gg24 » Unassigned
Status: Active » Needs review
StatusFileSize
new1.85 KB

Adding a patch. Please review.

Thanks!

  • gg24 committed bd316d3 on 8.x-2.x
    Issue #2894914 by gg24, ls206, geovanni.conti, faline: End date...
gg24’s picture

Status: Needs review » Fixed

Fixed.

Thanks everyone for your efforts.

othermachines’s picture

Unfortunately the last patch overrides the value with the start date again.

This works for me:

if (empty($end_date)) {
  $end_date = $date;
  if (!empty($build['addtocalendar'][$index]['atc_date_end']['#value'])) {
    $end_date = new DrupalDateTime(preg_replace('/T/', ' ', $build['addtocalendar'][$index]['atc_date_end']['#value']), 'UTC');
  }
  $build['addtocalendar'][$index]['atc_date_end']['#value'] = $end_date->format('Y-m-d H:i:s', ['timezone' => $timeZone]);
}

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.