Can this work with Datetime Range, and pull in start and end date values?

Created on 13 January 2023, almost 2 years ago
Updated 7 September 2024, 3 months ago

Using Drupal 9.3.22, Calendar Link 2.1.4. It works greate for Date and Time field. But I am using the Datetime Range field. In the twig template node--page.html.twig, I added this:

{% set link = calendar_link('google', node.title, node.field_date_range.value, node.field_date_range.end_value, node.body) %}
<a href="{{ link }}">Add to calendar</a>

I get the error: Could not get date and time from input value 2023-01-16T07:14:26 ()
The correct start date is shown in the error.

I found in this post ✨ Views support Fixed , they are using split to separate the start and end date. I could not get split to work.

This works, but the time is 12am for both start and end time

{% set link = calendar_link('google', node.title, node.field_date_range.start_date, node.field_date_range.end_date, node.body) %}
<a href="{{ link }}">Add to calendar</a>

I tried to add the time, but get error - Could not get date and time from input value Monday Jan 16 2:14 AM ()

{% set link = calendar_link('google', node.title, node.field_date_range.start_date|date(format='l M j g:i A'), node.field_date_range.end_date|date(format='l M j g:i A'), node.body) %}
<a href="{{ link }}">Add to calendar</a>

I tried to convert the date to ISO 8601
I get the error Could not get date and time from input value 2023-01-16T02:14:26-05:00 ()

{% set link = calendar_link('google', node.title, node.field_date_range.start_date|date("c"), node.field_date_range.end_date|date("c"), node.body) %}
<a href="{{ link }}">Add to calendar</a>
πŸ’¬ Support request
Status

Closed: outdated

Version

2.1

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States leisurman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024