Time offset tamper

Created on 7 March 2022, over 3 years ago
Updated 30 March 2023, over 2 years ago

Problem/Motivation

Feed source has a UTC timestamp but is being converted into the wrong timezone that is configured in the feed and field. Need a way offset the timestamp to be convert properly.

Steps to reproduce

Create a node with a date field with a certain timezone. Create a feed import and map to the date field with the chosen timezone. Feed source datetime should be a UTC timestamp.

Proposed resolution

Create a new tamper to offset time.

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada mmaranao Calgary, AB

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.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    It's interesting as we just had a related discussion in the ECA issue queue about a time zone topic here: 🌱 Example model for working with Dates, Timezones and Daylight Savings Time Fixed

    Looking into the patch and reading the comment from @mmaranao I wonder if this could be done as a tamper plugin that extends the existing timestamp-to-date plugin with the enhancements, that a time zone can be selected, and the tamper plugin would then do all the necessary math to format the given timestamp for the selected time zone. That could be done by using the DateTime class from PHP and would then also allow all the "strange" timezones like "+4:30" and others too.

  • πŸ‡ΊπŸ‡ΈUnited States sgroundwater

    I worked out an updated patch that may allow for better functionality, This patch adds a Timezone select list.

  • The last submitted patch, 6: 0001-Issue-3268276-Reworking-timezones.patch, failed testing. View results β†’
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Status changed to Needs work over 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This looks great to me, I guess you only need to add this new plugin to the schema file to fix the tests. And maybe the timezone field should be declared required in the config form. Other than that, it is really helpful and much appreciated.

  • πŸ‡³πŸ‡±Netherlands megachriz

    Thanks for the patch! In order for this to be merged, automated tests are needed as well. And I see some coding standard violations.

  • πŸ‡ΊπŸ‡ΈUnited States sgroundwater

    Thanks for the feedback! I'll work on these items to move things forward.
    - clean up for coding standards
    - declared timezone field as required in the config form
    - add tests

  • πŸ‡«πŸ‡·France PhilY πŸ‡ͺπŸ‡ΊπŸ‡«πŸ‡· Paris, France

    Patch works for offsetting time only, could it be extended to handle date offset so one can get a date with a '-3 months' offset?

  • Hi, i have created a simple Dateoffset plugin according to TimeOffset.

    Base data is timestamp too, and you can use tokens in the offset field like: "+[token] month".

    Please review the code, i didn’t had much time, just needed the function.

  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    @nitrocad your patch failed for me.

  • @nitrocad @eswiderski that's not a patch, that's a PHP source file renamed to .txt
    It appears to also have some issues such as missing definition for config name and mixing of tab and space indentation.
    I have corrected these issues in a new patch file.

  • πŸ‡³πŸ‡±Netherlands megachriz

    @starlight-sparkle
    Thanks for your contribution! Can you put your changes in a MR? The testbot on drupal.org no longer looks at patches, so changes need to be in a MR now if you want that the code eventually gets added to the module.

Production build 0.71.5 2024