public function testAddTo() { $start = DateTime::create('21.11.1984 13:00'); $iv = DateInterval::create('1 DAY'); $this->assertEquals('22.11.1984 13:00', $iv->addTo($start)->format('d.m.Y H:i')); $this->assertEquals('21.11.1984 13:00', $start->format('d.m.Y H:i')); }
/** */ public function updateTimestamps() { if (!isset($this->created)) { $this->created = \Psc\DateTime\DateTime::now(); } $this->modified = \Psc\DateTime\DateTime::now(); return $this; }
public function provideValidData() { $data = function ($date, $time) { return array('date' => $date, 'time' => $time); }; $optionalTimeRule = new DateTimeValidatorRule($timeIsOptional = TRUE); return array(array($data('12.02.2012', '12:12'), DateTime::create('12.02.2012 12:12')), array($data('12.02.2012', '12:12'), DateTime::create('12.02.2012 12:12')), array($data('29.02.2012', '12:12'), DateTime::create('29.02.2012 12:12')), array($data('28.02.1970', '00:01'), DateTime::create('28.02.1970 00:01')), array($data('12.02.2012', NULL), DateTime::create('12.02.2012 00:00'), $optionalTimeRule), array($data('12.02.2012', NULL), DateTime::create('12.02.2012 00:00'), $optionalTimeRule), array($data('29.02.2012', ''), DateTime::create('29.02.2012 00:00'), $optionalTimeRule), array($data('28.02.1970', NULL), DateTime::create('28.02.1970 00:00'), $optionalTimeRule)); }
public function __construct(Calendar $calendar, $title) { $this->title = $title; $this->calendar = $calendar; $this->created = DateTime::now(); $this->stamp = DateTime::now(); // Kein plan was der unterschied zu created ist $this->modified = DateTime::now(); }
/** * (at)ORM\PrePersist * (at)ORM\PreUpdate */ public function onPrePersist() { $this->generateSlugs(); if (!isset($this->created)) { $this->created = \Psc\DateTime\DateTime::now(); } $this->updated = \Psc\DateTime\DateTime::now(); return $this; }
public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } $val = \Psc\DateTime\DateTime::parse($platform->getDateTimeFormatString(), $value); if (!$val) { throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString()); } return $val; }
protected function init() { if ($this->type == 'atom') { $this->title = (string) $this->xml->title; $this->pubDate = DateTime::parse(DateTime::ATOM, (string) $this->xml->published); $this->link = (string) $this->xml->link['href']; } else { $this->title = (string) $this->xml->title; $this->link = (string) $this->xml->link; $this->description = (string) $this->xml->description; $this->pubDate = DateTime::parse(DateTime::RSS, (string) $this->xml->pubDate); } }
/** * * Empty Data ist NULL * * @return DateTime */ public function validate($data) { if (is_integer($data) && $data > 0) { return new DateTime($data); } if ($data === NULL || !is_array($data) || !array_key_exists('date', $data) || $data['date'] == NULL || !$this->timeIsOptional && (!array_key_exists('time', $data) || $data['time'] == NULL)) { throw EmptyDataException::factory(NULL); } $data['time'] = !isset($data['time']) ? NULL : trim($data['time']); $dateRule = new DateValidatorRule('d.m.Y'); $date = $dateRule->validate($data['date']); // cooler: time validator rule if ($this->timeIsOptional && $data['time'] == NULL) { return new DateTime($date); // sets time to 00:00 } else { return DateTime::parse('d.m.Y H:i', $date->format('d.m.Y') . ' ' . $data['time']); } }
public function testConstruct() { $invoice = new Invoice(Invoice::createPersonData(array('firstName' => 'Philipp', 'name' => 'Scheit', 'telephone' => '+49 69 15627503', 'company.title' => 'Web- und Softwareentwicklung', 'address.street' => 'Senefelderweg 8', 'address.zip' => 60435, 'address.countryCode' => 'D', 'address.city' => 'Frankfurt am Main', 'taxId' => 'DE280778214')), Invoice::createRecipientData(array('company.title' => 'Recipient Company Title', 'company.department' => 'WWS Accounting-Compartment', 'company.co' => 'z.Hd. Frau Dr. Musterdame', 'address.street' => 'Tulpenweg 1', 'address.zip' => 60486, 'address.countryCode' => 'D', 'address.city' => 'Frankfurt am Main')), Invoice::createInvoiceData(array('dateTime' => DateTime::factory('19.01.2012 15:23'), 'labelId' => '120119-080', 'place' => NULL, 'performancePeriod' => '01.09.2011 – 19.01.2012', 'text' => 'Der Rechnungsbetrag ist die zweite Hälfte der besprochenen Kosten im Angebot „Programmierung mit viel Aufwand“ vom 15. August 2011. Bitte überweisen sie den Rechnungsbetrag ohne Abzug auf das folgende Konto: Philipp Scheit Nr: 5405278345 BLZ: 500 105 17 Ing-Diba AG Ich bedanke mich für Ihren Auftrag und die nette Zusammenarbeit. Mit freundlichen Grüßen Philipp Scheit')), $items = new InvoiceItems()); $items->addItem(new SimpleInvoiceItem('Programmierung mit viel Aufwand', new Price(3600, Price::NETTO, 0.19))); $items->addItem(new SimpleInvoiceItem('Zusatzkosten Abstimmung', new Price(476, Price::BRUTTO, 0.19))); // simple getters $this->assertInstanceOf('Webforge\\Common\\DateTime\\DateTime', $invoice->getData()->getDateTime()); $this->assertEquals(60435, $invoice->getPerson()->get('address.zip')); $this->assertEquals('z.Hd. Frau Dr. Musterdame', $invoice->getRecipient()->get('company.co')); $this->assertInstanceOf('Psc\\Data\\Accounting\\InvoiceItems', $invoice->getItems()); }
public function loadFromData() { require $GLOBALS['env']['root']->getFile('tests/files/fixtures/EpisodesData.php'); foreach ($episodes as $row) { $row = (object) $row; list($tvShowName, $seasonNum, $seasonLang) = $seasonMappings[$row->season_id]; $episode = new Episode(); $episode->setIdentifier($row->id)->setLanguages($row->languages ? (array) unserialize(stripslashes($row->languages)) : array($seasonLang))->setSeason($season = $this->getSeason($tvShowName, $seasonNum, $seasonLang))->setNum((int) $row->num)->setStatus($row->status)->setInfo($row->info)->setTitle($row->title)->setRelease($row->releasegroup)->setLink($row->link)->setSection($row->section)->setDiscoveredTime(DateTime::createFromMysql($row->discoveredTime)); if ($row->finishedTime) { $episode->setFinishedTime(DateTime::createFromMysql($row->finishedTime)); } if ($row->downloadedTime) { $episode->setDownloadedTime(DateTime::createFromMysql($row->downloadedTime)); } $this->episodes[$tvShowName][$season->getNum()][] = $episode; } }
/** * @expectedException InvalidArgumentException */ public function testSetYearBecomesInt() { $date = DateTime::now(); $date->setYear('2011'); }
public function testDateTimeExporting() { $type = new DateTimeType(); $value = new DateTime('21.11.1984 17:21:00'); $this->assertEquals((object) array('date' => $value->getTimestamp(), 'timezone' => date_default_timezone_get()), $this->objectExporter->walk($value, $type)); }
/** * @return NULL|Psc\DateTime\DateTime */ public function getDate() { $str = $this->getField('Date'); if ($str !== NULL) { //DateTime::COOKIE /* @TODO parseDate in HTTP:: Klasse HTTP applications have historically allowed three different formats for the representation of date/time stamps: Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format */ return DateTime::parse(DateTime::RFC1123, $str); } return NULL; }
public function __construct($label) { $this->label = $label; $this->created = \Psc\DateTime\DateTime::now(); $this->articles = new ArrayCollection(); }
public function updateStatusTimestamp() { if ($this->status === Status::FINISHED) { $this->finishedTime = DateTime::now(); } elseif ($this->status == Status::DISCOVERED) { $this->discoveredTime = DateTime::now(); } elseif ($this->status == Status::DOWNLOADED) { $this->downloadedTime = DateTime::now(); } return $this; }
/** * * date = date-value date-value = date-fullyear date-month date-mday date-fullyear = 4DIGIT date-month = 2DIGIT ;01-12 date-mday = 2DIGIT ;01-28, 01-29, 01-30, 01-31 ;based on month/year time = time-hour time-minute time-second [time-utc] time-hour = 2DIGIT ;00-23 time-minute = 2DIGIT ;00-59 time-second = 2DIGIT ;00-60 ;The "60" value is used to account for "leap" seconds. time-utc = "Z" */ public function icalDateTime(\Psc\DateTime\DateTime $dateTime) { return $dateTime->format(self::ICAL_DATE . '\\T' . self::ICAL_TIME); }