/** * Returns the value, in the format it should be encoded for json. * * This method must always return an array. * * @return array */ function getJsonValue() { $values = []; foreach ($this->getParts() as $k => $v) { if (strcmp($k, 'UNTIL') === 0) { $date = new DateTime($this->root, null, $v); $values[strtolower($k)] = $date->getJsonValue()[0]; } else { $values[strtolower($k)] = $v; } } return [$values]; }
function testGetDateTimeCached() { $tz = new \DateTimeZone('Europe/Amsterdam'); $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); $elem = $this->vcal->createProperty('DTSTART'); $elem->setDateTime($dt); $this->assertEquals($elem->getDateTime(), $dt); }
function testSetParts() { $tz = new \DateTimeZone('Europe/Amsterdam'); $dt1 = new \DateTime('1985-07-04 01:30:00', $tz); $dt2 = new \DateTime('1985-07-04 02:30:00', $tz); $dt1->setTimeZone($tz); $dt2->setTimeZone($tz); $elem = $this->vcal->createProperty('DTSTART'); $elem->setParts([$dt1, $dt2]); $this->assertEquals('19850704T013000,19850704T023000', (string) $elem); $this->assertEquals('Europe/Amsterdam', (string) $elem['TZID']); $this->assertNull($elem['VALUE']); $this->assertTrue($elem->hasTime()); }