From 0c35085c3b97a469693751ea64c1bd28a5ac5fdb Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Tue, 10 Nov 2009 16:26:31 +0100 Subject: [PATCH] Add toJson(). --- framework/Date/lib/Horde/Date/Recurrence.php | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/framework/Date/lib/Horde/Date/Recurrence.php b/framework/Date/lib/Horde/Date/Recurrence.php index d5a1c9bb1..0d282f8ba 100644 --- a/framework/Date/lib/Horde/Date/Recurrence.php +++ b/framework/Date/lib/Horde/Date/Recurrence.php @@ -1528,4 +1528,42 @@ class Horde_Date_Recurrence return $hash; } + /** + * Returns a simple object suitable for json transport representing this + * object. + * + * Possible properties are: + * - t: type + * - i: interval + * - e: end date + * - c: count + * - d: data + * - co: completions + * - ex: exceptions + * + * @return object A simple object. + */ + public function toJson() + { + $json = new stdClass; + $json->t = $this->recurType; + $json->i = $this->recurInterval; + if ($this->recurEnd) { + $json->e = $this->recurEnd->toJson(); + } + if ($this->recurCount) { + $json->c = $this->recurCount; + } + if ($this->recurData) { + $json->d = $this->recurData; + } + if ($this->completions) { + $json->co = $this->completions; + } + if ($this->exceptions) { + $json->ex = $this->exceptions; + } + return $json; + } + } -- 2.11.0