Hi,

I'm using this module and I've found a problem when I want to repeat a class across two different years. This is my context:

I have a node type called "Class".
I add a new class and I want to repeat it from 2015-12-14 to 2016-01-15, every Monday and every Wednesday.
The module generates the following classes:

Monday, 2015-12-14
Wednesday, 2015-12-16
Monday, 2015-12-23
Wednesday, 2015-12-25
Tuesday, 2016-01-05 Wrong value!
Wednesday, 2016-01-05
Monday, 2016-01-11
Wednesday, 2016-01-13

Every time I want to repeat a node, when the year changes, the first day is wrong...

Could somebody help me?

Thanks!

CommentFileSizeAuthor
#5 node_recur-leap_year-2575079-1.patch1.41 KBdromansab

Comments

dromansab created an issue. See original summary.

raycascella’s picture

Hi dromansab. Wow, nice catch. I'm seeing the issue as well. It seems to happen only when a date lands on the first of the month? There is a ton of extra logic in place when generating the days, that was all done manually. That's what's causing the issue. I'm not exactly sure which code block is the culprit, though. I think it' s adjusting the hours back to the previous day? I'm still testing for other scenarios that match the outcome.

I've been working on removing the custom generation code and letting drupal/php core datetime functions do the heavy lifting, in the 7.x-2.x branch, but it's HIGHLY unstable, which is why it's unreleased. That version shouldn't come across this issues, but I'm still working on a 7.x-1.x patch now. However, it's taking longer than I thought.

Unfortunately, the only work around I've found is to manually update the the field to the correct value after creation, or removal if it's created and extra node. I'll update this ticket once I get the patch working.

dromansab’s picture

Hi,

thanks for your reply. I think I've found the bug...

In function called node_recur_generate_dates_days, in this piece of code:

      // If days apart is negative, we've jumped to a new year
      if ($days_apart < 0) {
        // Use 366 instead of 365 because the first day is 1, not 0
        $days_apart += 366;
      }

If I set $days_apart += 365, it works correctly. Could you try it? And could you explain why did you set 366?

Thanks!

dromansab’s picture

May you develop it on a leap-year? :)

dromansab’s picture

StatusFileSize
new1.41 KB

Definitely, it is because of the leap-year...

I've made a patch that checks if year is a leap-year and uses 365 or 366.

d34dman’s picture

Wow good catch :)