Closed (fixed)
Project:
Tamper
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
7 Mar 2022 at 23:29 UTC
Updated:
10 Jul 2026 at 17:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mmaranao commentedCreate a time offset tamper to offset the datetime on import.
Comment #3
mmaranao commentedUpdate patch path and description.
Comment #4
megachrizThis should go into the Tamper project.
The options do look like to be somewhat limited. Also, I think that the use case would already be covered by the Tamper plugin "Math"?
Do know that with Feeds date target you can configure which timezone should be used when interpreting the source value. Or doesn't that work if the input value is a timestamp (numeric value)?
Comment #5
jurgenhaasIt's interesting as we just had a related discussion in the ECA issue queue about a time zone topic here: #3351165: Example model for working with Dates, Timezones and Daylight Savings Time
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.
Comment #6
sgroundwater commentedI worked out an updated patch that may allow for better functionality, This patch adds a Timezone select list.
Comment #8
jurgenhaasThis 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.
Comment #9
megachrizThanks for the patch! In order for this to be merged, automated tests are needed as well. And I see some coding standard violations.
Comment #10
sgroundwater commentedThanks 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
Comment #11
philyPatch works for offsetting time only, could it be extended to handle date offset so one can get a date with a '-3 months' offset?
Comment #12
nitrocad commentedHi, 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.
Comment #13
eswiderski commented@nitrocad your patch failed for me.
Comment #14
starlight-sparkle@nitrocad @eswiderski that's not a patch, that's a PHP source file renamed to
.txtIt 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.
Comment #15
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.
Also, it needs to have a functional test and a unit test for it to be accepted.
Comment #16
mortona2k commentedThe offset works, but I need to apply a reverse offset to save the current time in a date field.
With ECA, I can get the current datetime from [current-date]. If my timezone is -8hrs, then the token value is in my time and saving it will make it 8 hours in the past.
I need an offset function to reverse the timezone offset to save the value in UTC.
Comment #18
starlight-sparkle@mortona2k for your ECA use-case, you can use
[current-date:raw]which is a Unix timestamp, which is timezone-agnostic.Comment #19
starlight-sparkleConverted #6 and #14 into an MR, with added tests.
There are some test failures, but they appear to originate from the base branch (Drupal Core API has changed since last test in 8.x-1.x 3 months ago).
Comment #22
mandclu commentedThanks for everyone's work here. With the changes merged in from the main branch, the tests output is clean. Merged in.
Comment #23
mandclu commented