User timezone should be available as a token

Created on 26 June 2017, over 7 years ago
Updated 31 March 2023, almost 2 years ago

Problem/Motivation

Currently, if you render tokens for message, all timestamps are rendered by using current user. With multilingual (and multi-timezoned) this becomes a bit tricky.

In scenario, where there's mail including datetime token being sent to recipient from queue, and the queue is ran in cron, the current user is anonymous, which does not have timezone. This leads in situation where the datetime is default timezone.

The solution for above is to use `account_switcher` service when handling the queue to set current user to be the recipient.

However, if you like to let the user know what timezone was actually used for the timestamps, you would probably add something like
All times are shown as timezone of [current-user:timezone]

And for some reason, this isn't yet possible.

Proposed resolution

Adds a "timezone" user token, which gets either the user's timezone or the default time zone.

Remaining tasks

- Edit the change record for language and code examples following other change records

User interface changes

Adds a new token.
Adds a new translatable string: "The timezone of the user account."

API changes

N/A

Data model changes

N/A

Release notes snippet

Feature request
Status

Needs work

Version

10.1

Component
Token 

Last updated 16 days ago

No maintainer
Created by

🇫🇮Finland dropa

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

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