From e86787a8eb6a31fbe95f1a3854d66e25e5e63c67 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 23 Jan 2014 17:05:49 +0100 Subject: html renderer, console renderer uses pear's Console_Table --- src/bdrem/Event.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/bdrem/Event.php') diff --git a/src/bdrem/Event.php b/src/bdrem/Event.php index 65e4b9b..43b9c92 100644 --- a/src/bdrem/Event.php +++ b/src/bdrem/Event.php @@ -21,6 +21,22 @@ class Event */ public $date; + /** + * Reference date against which $age and $days are calculated + * (often today) + * + * @var string YYYY-MM-DD + */ + public $refDate; + + /** + * "Localized" $date used for calculations against $refDate. + * Month and day are the same as in $date, year is near $refDate's year. + * + * @var string YYYY-MM-DD + */ + public $localDate; + /** * Which repetition this is * @@ -52,10 +68,12 @@ class Event */ public function isWithin($strDate, $nDaysBefore, $nDaysAfter) { + $this->refDate = $strDate; list($rYear, $rMonth, $rDay) = explode('-', $strDate); list($eYear, $eMonth, $eDay) = explode('-', $this->date); if ($rMonth == $eMonth && $rDay == $eDay) { + $this->localDate = $strDate; $this->days = 0; if ($eYear == '????') { $this->age = null; @@ -72,8 +90,9 @@ class Event $yearOffset = -1; } + $this->localDate = ($rYear + $yearOffset) . '-' . $eMonth . '-' . $eDay; $rD = new \DateTime($strDate); - $eD = new \DateTime(($rYear + $yearOffset) . '-' . $eMonth . '-' . $eDay); + $eD = new \DateTime($this->localDate); $nDiff = (int) $rD->diff($eD)->format('%r%a'); -- cgit v1.2.3