Download & Extend

how to use date_repeat_calc ?

Project:Date
Version:7.x-2.6
Component:Date Repeat API
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

hello
using :

Drupal 7.19
PHP Version 5.4.6-1ubuntu1.1 / 64 bits

here is what is displayed in the node output :
Repeats every week every Friday until Fri Feb 22 2013 except Fri Jan 18 2013, Fri Feb 08 2013. Also includes Fri Mar 22 2013, Fri Mar 29 2013.
Friday, January 4, 2013 - 00:30 to 00:45

this is correct.

here is what i have when i get the field values using node_load :

array(
        'value' => '2013-01-03 23:30:00',
        'value2' => '2013-01-03 23:45:00',
        'rrule' => "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=FR;UNTIL=20130222T225959Z;WKST=SU\r\nEXDATE:20130117T230000Z,20130207T230000Z\r\nRDATE:20130321T230000Z,20130328T230000Z",
        'timezone' => 'Europe/Berlin',
        'timezone_db' => 'UTC',
        'date_type' => 'datetime',
      ),

this is not correct.

here is what i am asking to date_repeat_calc (taking the same values as the field result) :

<?php
$start
= "2013-01-03 23:30:00";
$end = "2014-01-03 23:45:00"; // changed to 2014 because without this i have only one date in return
$timezone = "Europe/Berlin"; // UTC
$rrule = "RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=FR;UNTIL=20130222T225959Z;WKST=SU";
$exceptions = array("20130117T230000Z","20130207T230000Z");
$additions = array("20130321T230000Z","20130328T230000Z");
$dates = date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additions);
?>

here is what i have in return :
array(
  '2013-01-03 23:30:00',
  '2013-01-04 23:30:00',
  '2013-01-11 23:30:00',
  '2013-01-18 23:30:00',
  '2013-01-25 23:30:00',
  '2013-02-01 23:30:00',
  '2013-02-08 23:30:00',
  '2013-02-15 23:30:00',
  '2013-02-22 23:30:00',
  '2013-03-21 23:00:00',
  '2013-03-28 23:00:00',
)

the additionnal dates are added.
the excluded dates are not removed.
i have tried using 2330 as time for excluded dates and i have also tried using the same dates as i have entered in the node form (jan 4) and the excluded dates are not returned also.

did i forget something or is there a bug ?

Comments

#1

I think you're formats in your exceptions and additions are off.

I'm pretty sure those need to be in Y-m-d format.

Try this:

<?php
$exceptions
= array("2013-01-17","2013-02-07");
$additions = array("2013-03-21","2013-03-28");
?>