public function last_modified() { $lastModified = new Date('2012-12-07 15:05:00', TimeZone::getByName('Europe/Berlin')); $n = new Node('record'); (new ContentRecord('http://localhost/'))->lastModified($lastModified)->visit($n); $this->assertEquals('Fri, 07 Dec 2012 15:05:00 +0100', $n->getAttribute('last-modified')); }
/** * Format a date by the given strftime()-like format string. * * These format tokens are not supported intentionally: * %a, %A, %b, %B, %c, %h, %p, %U, %x, %X * * @see php://strftime * @param string format * @param util.TimeZone outtz default NULL * @return string * @throws lang.IllegalArgumentException if unsupported token has been given */ public function format($format, TimeZone $outtz = null) { return preg_replace_callback('#%([a-zA-Z%])#', [$outtz === null ? $this : $outtz->translate($this), 'formatCallback'], $format); }
/** * Write response headers * * @param scriptlet.Response response * @param peer.URL base * @param string format */ protected function writeHead($response, $base, $format) { $response->setContentType($this->mediaType); if (null !== $this->contentLength) { $response->setContentLength($this->contentLength); } if (null !== $this->lastModified) { $response->setHeader('Last-Modified', \util\TimeZone::getByName('GMT')->translate($this->lastModified)->toString('D, d M Y H:i:s \\G\\M\\T')); } }
public function parse_canonical() { $this->assertEquals(['canonical' => new Date('2001-12-15 02:59:43', \util\TimeZone::getByName('GMT'))], $this->parse('canonical: 2001-12-15T02:59:43.1Z')); }
/** * Format a date by the given strftime()-like format string. * * These format tokens are not supported intentionally: * %a, %A, %b, %B, %c, %h, %p, %U, %x, %X * * @see php://strftime * @param string $format * @param util.TimeZone $outtz default NULL * @return string * @throws lang.IllegalArgumentException if unsupported token has been given */ public function format(string $format, TimeZone $outtz = null) : string { static $replace = ['%d' => 'd', '%m' => 'm', '%Y' => 'Y', '%H' => 'H', '%S' => 's', '%w' => 'w', '%G' => 'o', '%D' => 'm/d/Y', '%T' => 'H:i:s', '%z' => 'O', '%Z' => 'e', '%G' => 'o', '%V' => 'W', '%C' => 'y', '%e' => 'j', '%G' => 'o', '%H' => 'H', '%I' => 'h', '%j' => 'z', '%M' => 'i', '%r' => 'h:i:sa', '%R' => 'H:i:s', '%u' => 'N', '%V' => 'W', '%W' => 'W', '%w' => 'w', '%y' => 'y', '%Z' => 'O', '%t' => "\t", '%n' => "\n", '%%' => '%']; return date_format(($outtz === null ? $this : $outtz->translate($this))->handle, strtr($format, $replace)); }