9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/bdrem.htm
17 * Reads birthday reminder 2's birthday files (.bdf).
21 * @author Christian Weiske <cweiske@cweiske.de>
22 * @copyright 2014 Christian Weiske
23 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
24 * @link http://cweiske.de/bdrem.htm
29 * Full path of bdf birthday file
35 * Set the birthday file name
37 * @param string $filename Path to bdf file
39 public function __construct($filename)
41 $this->filename = $filename;
42 if (!file_exists($this->filename)) {
44 'Birthday file does not exist: ' . $this->filename
50 * Return all events for the given date range
52 * @param string $strDate Date the events shall be found for,
54 * @param integer $nDaysPrevious Include number of days before $strDate
55 * @param integer $nDaysNext Include number of days after $strDate
57 * @return Event[] Array of matching event objects
59 public function getEvents($strDate, $nDaysPrevious, $nDaysNext)
61 $x = simplexml_load_file($this->filename);
64 foreach ($x->content->person as $xPerson) {
68 explode('.', (string) $xPerson->date)
72 (string) $xPerson->name,
73 (string) $xPerson->event,
76 if ($event->isWithin($strDate, $nDaysPrevious, $nDaysNext)) {