Smart date range stopped working with 4.0.11

Created on 3 July 2025, about 1 month ago

Problem/Motivation

I've been using Date iCal in conjunction with a smart date range successfully for a while in a D10 site. I create a public feed.ics from my events and can offer public subscription to the feed.

After the upgrade to 4.0.11, the feed is now broken. The error message is:

DateMalformedStringException: Failed to parse time string (1751644800) at position 8 (0): Unexpected character in DateTime->__construct() (line 46 of /var/www/html/drupal/web/modules/contrib/date_ical/src/DateICal.php).

I know that smart dates were problematic at some point, and then it seems that the basics (no recurring dates) worked in 4.0.10. So I'm not sure if the maintainers officially considered basic smart dates supported.

Demo video

Steps to reproduce

  1. create an event content type with smart date range field
  2. create a view for this content type with a Date iCal feed display
  3. use the smart date field for the feed date, using default formatter

Proposed resolution

The handling of numeric timestamps changed in 4.0.11, and it seems that, instead of creating a date first, the module is now plugging the numeric timestamp directly into a new \DateTime:

# v4.0.10
if (is_numeric($start)) {
  $start = date('Y-m-d\TH:i:s', (int) $start);
}
# v4.0.11
if (is_numeric($start)) {
  $start = new \DateTime($start, $dateUTCTimeZone);
}
πŸ“Œ Task
Status

Active

Version

4.0

Component

iCal Export

Created by

πŸ‡ΊπŸ‡ΈUnited States mkindred

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

Comments & Activities

  • Issue created by @mkindred
  • πŸ‡ΊπŸ‡ΈUnited States micahw156

    I see two ways to fix this problem. The first is a quick fix to add the @ character before the integer value when creating a new \DateTime() object.

    diff --git a/src/DateICal.php b/src/DateICal.php
    index 5610597..d35cb67 100644
    --- a/src/DateICal.php
    +++ b/src/DateICal.php
    @@ -43,7 +43,7 @@ class DateICal implements DateICalInterface {
             $end = $field['end_field']['value'];
           }
           if (is_numeric($start)) {
    -        $start = new \DateTime($start, $dateUTCTimeZone);
    +        $start = new \DateTime("@$start", $dateUTCTimeZone);
           }
           else {
             if (strlen($start) === 10) {
    @@ -58,7 +58,7 @@ class DateICal implements DateICalInterface {
     
           if (!empty($end)) {
             if (is_numeric($end)) {
    -          $end = new \DateTime($end, $dateUTCTimeZone);
    +          $end = new \DateTime("@$end", $dateUTCTimeZone);
             }
             else {
               if (strlen($end) === 10) {
    

    It would also be possible to fix this by implementing DrupalDateTimePlus, but that seems like a bad idea unless converting the entire service to use this approach.

  • πŸ‡«πŸ‡·France lazzyvn paris

    Actually, from beginning, I did not intend to support the smart date module because its data storage structure is completely different from date time and date rage module in drupal core. After supporting smart date, a series of timezone problems appeared, so in the new version, I was forced to prioritize standard drupal fields than supporting smartdate. You can go back last version or wait new version

  • πŸ‡«πŸ‡·France lazzyvn paris
  • πŸ‡ΊπŸ‡ΈUnited States micahw156

    Thanks!

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

Production build 0.71.5 2024