Adjust smart date twig function to factor in timezone

Created on 16 May 2024, 6 months ago
Updated 10 September 2024, 2 months ago

Problem/Motivation

The current smart date twig function `smart_date_format` does not currently take the timezone into account when formatting a smart date field value. There is currently a todo in the code that says as much. This issue should address that by factoring timezone into the mix!

Steps to reproduce

Output the date/time of a smart date field as such:

{{ node.field_event_date|smart_date_format('extended') }}

The function will not take the current field's timezone configuration/user selections (i.e. if the user selected the timezone) into account.

Proposed resolution

The twig function currently relies on `formatSmartDate` from `SmartDateTrait.php`. This function already accepts a timezone, so we just need to update the invocation of `formatSmartDate` in `web/modules/contrib/smart_date/src/TwigExtension/SmartDateFormat.php` to pass it along.

Remaining tasks

Create merge request/upload patch.

πŸ› Bug report
Status

Needs review

Version

4.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States malik.kotob

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024