]> git.mxchange.org Git - friendica-addons.git/blob - curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Time.php
minor additions to the README
[friendica-addons.git] / curweather / vendor / cmfcmf / openweathermap-php-api / Cmfcmf / OpenWeatherMap / Util / Time.php
1 <?php
2 /**
3  * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
4  *
5  * @license MIT
6  *
7  * Please see the LICENSE file distributed with this source code for further
8  * information regarding copyright and licensing.
9  *
10  * Please visit the following links to read about the usage policies and the license of
11  * OpenWeatherMap before using this class:
12  *
13  * @see http://www.OpenWeatherMap.org
14  * @see http://www.OpenWeatherMap.org/terms
15  * @see http://openweathermap.org/appid
16  */
17
18 namespace Cmfcmf\OpenWeatherMap\Util;
19
20 /**
21  * The time class representing a time object.
22  */
23 class Time
24 {
25     /**
26      * @var \DateTime The start time for the forecast.
27      */
28     public $from;
29
30     /**
31      * @var \DateTime The end time for the forecast.
32      */
33     public $to;
34
35     /**
36      * @var \DateTime The day of the forecast.
37      */
38     public $day;
39
40     /**
41      * Create a new time object.
42      *
43      * @param string|\DateTime $from The start time for the forecast.
44      * @param string|\DateTime $to   The end time for the forecast.
45      *
46      * @internal
47      */
48     public function __construct($from, $to = null)
49     {
50         if (isset($to)) {
51             $from = ($from instanceof \DateTime) ? $from : new \DateTime((string)$from);
52             $to = ($to instanceof \DateTime) ? $to : new \DateTime((string)$to);
53             $day = new \DateTime($from->format('Y-m-d'));
54         } else {
55             $from = ($from instanceof \DateTime) ? $from : new \DateTime((string)$from);
56             $day = clone $from;
57             $to = clone $from;
58             $to = $to->add(new \DateInterval('PT23H59M59S'));
59         }
60
61         $this->from = $from;
62         $this->to = $to;
63         $this->day = $day;
64     }
65 }