Download & Extend

support date offsets in months

Project:Rules
Version:7.x-2.x-dev
Component:Rules Core
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Currently date offsets in days/months/years are not properly supported, as internally date offsets are always applied in seconds. However the number of seconds of a day (due to DST), a month and a year varies. Because of that we'll have to build in specific support for applying offsets of e.g. 1 month.

Comments

#1

Component:Rules Core» Rules Engine
Status:active» fixed

implemented: http://drupalcode.org/project/rules.git/commit/ff728b9

As the entity api specifies that durations have to be represented in seconds, we cannot really change the storage format of duration and properly differentiate between e.g. 86400 * 30 seconds or "1 month". However, usually 1 month will be the desired duration so we'll just go with the higher units (years, months, days) if the number of (stored) seconds is high enough. For that I've baked in the assumption that 1 day == 24hours, 1 month == 30 days and 1 year == 12 months.

#2

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#3

Status:closed (fixed)» needs review

Unfortunately the changes do not work in PHP 5.2, as there the date modify function returns NULL instead of the DateTime object (see http://www.php.net/manual/en/datetime.modify.php), leading to a PHP error in 5.2.

Attached patch fixes the code for PHP versions prior to 5.3

AttachmentSizeStatusTest resultOperations
rules_date_offset_modify_5_2.patch652 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch rules_date_offset_modify_5_2.patch. Unable to apply patch. See the log in the details link for more information.View details

#4

Status:needs review» fixed

thanks, committed.

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here