When adding a fixed date condition to a rule, re-saving the condition adds or subtracts the difference between the local time and GMT each time.
My timezone in Regional settings is set to "America/Toronto", which is currently GMT -0500.
- Create a condition for
site:current-date, operator is greater than, data value 2012-12-28 06:00:00.
- Edit the condition. The form's data value is displayed as
2012-12-28 11:00:00, which is 5 hours ahead of the previously saved value.
- Save the condition.
Repeating these steps causes the data value to drift by +5 hours (or the difference from GMT) each time. It looks like this behaviour comes from RulesDataUIDate::inputForm(), which runs the saved timestamp through gmdate() each time the form is displayed.
Related: #1289566: Rules interface instructs to use GMT, but evaluation is against local time
Comments
Comment #1
star-szrRe-titling because I don't think this bug affects only conditions, it looks like it would affect the schedule functionality as well.
Comment #2
star-szrClearer title and technically this is a Rules UI bug.
Comment #3
brightboldI can confirm this is still a problem in the latest dev.
Comment #4
weiseng commentedDisplay the datetime using system default timezone instead of gmdate() to avoid confusion.
related issue: https://www.drupal.org/node/1289566
Comment #5
weiseng commentedComment #6
LuxianThanks @weiseng for the patch. It made my life easier today.
As for review, my only complain is regarding the field description text:
1. Maybe we can get away by not mentioning the timezone at all because it's confusing. First of all - I'm not sure what "system" means (Drupal or server). And even if it refers to Drupal system, it can be user's timezone and not the default Drupal timezone. The timezone used is set by Drupal according to the value returned by drupal_get_user_timezone() during bootstrap.
2. There is still a 'GMT' mention in that string.
Proposal:
Comment #7
tr commentedPatch needs to be re-rolled.