Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 399
Zeile 30... Zeile 30...
30
 
30
 
31
	/** week in seconds */
31
	/** week in seconds */
Zeile 32... Zeile 32...
32
	public const WEEK = 7 * self::DAY;
32
	public const WEEK = 7 * self::DAY;
33
 
33
 
Zeile 34... Zeile 34...
34
	/** average month in seconds */
34
	/** average month in seconds */
35
	public const MONTH = 2629800;
35
	public const MONTH = 2_629_800;
Zeile 36... Zeile 36...
36
 
36
 
37
	/** average year in seconds */
37
	/** average year in seconds */
38
	public const YEAR = 31557600;
-
 
39
 
-
 
40
 
38
	public const YEAR = 31_557_600;
41
	/**
39
 
42
	 * Creates a DateTime object from a string, UNIX timestamp, or other DateTimeInterface object.
40
 
43
	 * @param  string|int|\DateTimeInterface  $time
41
	/**
44
	 * @return static
42
	 * Creates a DateTime object from a string, UNIX timestamp, or other DateTimeInterface object.
45
	 * @throws \Exception if the date and time are not valid.
43
	 * @throws \Exception if the date and time are not valid.
Zeile 46... Zeile 44...
46
	 */
44
	 */
Zeile 62... Zeile 60...
62
	}
60
	}
Zeile 63... Zeile 61...
63
 
61
 
64
 
62
 
65
	/**
-
 
66
	 * Creates DateTime object.
63
	/**
67
	 * @return static
64
	 * Creates DateTime object.
68
	 * @throws Nette\InvalidArgumentException if the date and time are not valid.
65
	 * @throws Nette\InvalidArgumentException if the date and time are not valid.
69
	 */
66
	 */
70
	public static function fromParts(
67
	public static function fromParts(
71
		int $year,
68
		int $year,
72
		int $month,
69
		int $month,
73
		int $day,
70
		int $day,
74
		int $hour = 0,
71
		int $hour = 0,
-
 
72
		int $minute = 0,
75
		int $minute = 0,
73
		float $second = 0.0,
76
		float $second = 0.0
74
	): static
77
	) {
75
	{
78
		$s = sprintf('%04d-%02d-%02d %02d:%02d:%02.5F', $year, $month, $day, $hour, $minute, $second);
76
		$s = sprintf('%04d-%02d-%02d %02d:%02d:%02.5F', $year, $month, $day, $hour, $minute, $second);
79
		if (
77
		if (
80
			!checkdate($month, $day, $year)
78
			!checkdate($month, $day, $year)
Zeile 92... Zeile 90...
92
	}
90
	}
Zeile 93... Zeile 91...
93
 
91
 
94
 
92
 
95
	/**
-
 
96
	 * Returns new DateTime object formatted according to the specified format.
-
 
97
	 * @param  string  $format  The format the $time parameter should be in
-
 
98
	 * @param  string  $time
-
 
99
	 * @param  string|\DateTimeZone  $timezone (default timezone is used if null is passed)
93
	/**
-
 
94
	 * Returns new DateTime object formatted according to the specified format.
-
 
95
	 */
100
	 * @return static|false
96
	public static function createFromFormat(
101
	 */
97
		string $format,
-
 
98
		string $time,
102
	#[\ReturnTypeWillChange]
99
		string|\DateTimeZone|null $timezone = null,
103
	public static function createFromFormat($format, $time, $timezone = null)
100
	): static|false
104
	{
101
	{
Zeile 105... Zeile 102...
105
		if ($timezone === null) {
102
		if ($timezone === null) {
106
			$timezone = new \DateTimeZone(date_default_timezone_get());
103
			$timezone = new \DateTimeZone(date_default_timezone_get());
107
 
-
 
108
		} elseif (is_string($timezone)) {
-
 
109
			$timezone = new \DateTimeZone($timezone);
-
 
110
 
104
 
Zeile 111... Zeile 105...
111
		} elseif (!$timezone instanceof \DateTimeZone) {
105
		} elseif (is_string($timezone)) {
112
			throw new Nette\InvalidArgumentException('Invalid timezone given');
106
			$timezone = new \DateTimeZone($timezone);
113
		}
107
		}
Zeile 135... Zeile 129...
135
	}
129
	}
Zeile 136... Zeile 130...
136
 
130
 
137
 
131
 
138
	/**
-
 
139
	 * Creates a copy with a modified time.
132
	/**
140
	 * @return static
133
	 * Creates a copy with a modified time.
141
	 */
134
	 */
142
	public function modifyClone(string $modify = '')
135
	public function modifyClone(string $modify = ''): static
143
	{
136
	{
144
		$dolly = clone $this;
137
		$dolly = clone $this;
145
		return $modify ? $dolly->modify($modify) : $dolly;
138
		return $modify ? $dolly->modify($modify) : $dolly;