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

Created on 13 January 2023, over 1 year ago
Updated 2 November 2023, 8 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 β†’ , 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

Postponed: needs info

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.69.0 2024