ICanBoogie/HTTP v2.4.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Exception
    • HTTP
      • Dispatcher
      • Headers
      • Request

Classes

  • ICanBoogie\Exception\RescueEvent
  • ICanBoogie\HTTP\CallableDispatcher
  • ICanBoogie\HTTP\Dispatcher
  • ICanBoogie\HTTP\Dispatcher\BeforeDispatchEvent
  • ICanBoogie\HTTP\Dispatcher\DispatchEvent
  • ICanBoogie\HTTP\File
  • ICanBoogie\HTTP\FileInfo
  • ICanBoogie\HTTP\FileList
  • ICanBoogie\HTTP\Headers
  • ICanBoogie\HTTP\Headers\CacheControl
  • ICanBoogie\HTTP\Headers\ContentDisposition
  • ICanBoogie\HTTP\Headers\ContentType
  • ICanBoogie\HTTP\Headers\Date
  • ICanBoogie\HTTP\Headers\Header
  • ICanBoogie\HTTP\Headers\HeaderParameter
  • ICanBoogie\HTTP\Helpers
  • ICanBoogie\HTTP\RedirectResponse
  • ICanBoogie\HTTP\Request
  • ICanBoogie\HTTP\Request\Context
  • ICanBoogie\HTTP\Response
  • ICanBoogie\HTTP\Status
  • ICanBoogie\HTTP\WeightedDispatcher

Interfaces

  • ICanBoogie\HTTP\DispatcherInterface
  • ICanBoogie\HTTP\Exception

Exceptions

  • ICanBoogie\HTTP\DispatcherNotDefined
  • ICanBoogie\HTTP\ForceRedirect
  • ICanBoogie\HTTP\MethodNotSupported
  • ICanBoogie\HTTP\NotFound
  • ICanBoogie\HTTP\ServiceUnavailable
  • ICanBoogie\HTTP\StatusCodeNotValid
 1 <?php
 2 
 3 /*
 4  * This file is part of the ICanBoogie package.
 5  *
 6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
 7  *
 8  * For the full copyright and license information, please view the LICENSE
 9  * file that was distributed with this source code.
10  */
11 
12 namespace ICanBoogie\HTTP\Headers;
13 
14 use ICanBoogie\DateTime;
15 
16 /**
17  * A date time object that renders into a string formatted for HTTP header fields.
18  *
19  * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
20  */
21 class Date extends DateTime
22 {
23     static public function from($source, $timezone=null)
24     {
25         if ($source === null)
26         {
27             return static::none();
28         }
29 
30         return parent::from($source, $timezone);
31     }
32 
33     /**
34      * Constructor.
35      *
36      * @param string|int|\DateTime $time If time is provided as a numeric value it is used as
37      * "@{$time}" and the time zone is set to UTC.
38      * @param \DateTimeZone|string $timezone A {@link \DateTimeZone} object representing the desired
39      * time zone. If the time zone is empty `utc` is used instead.
40      */
41     public function __construct($time='now', $timezone=null)
42     {
43         if ($time instanceof \DateTime)
44         {
45             $time = $time->getTimestamp();
46         }
47 
48         if (is_numeric($time))
49         {
50             $time = '@' . $time;
51             $timezone = null;
52         }
53 
54         parent::__construct($time, $timezone ?: 'utc');
55     }
56 
57     /**
58      * Formats the instance according to the RFC 1123.
59      */
60     public function __toString()
61     {
62         return $this->is_empty ? '' : $this->utc->as_rfc1123;
63     }
64 }
65 
ICanBoogie/HTTP v2.4.0 API documentation generated by ApiGen