Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Faker\Extension;
4
 
5
/**
6
 * FakerPHP extension for Date-related randomization.
7
 *
8
 * Functions accepting a date string use the `strtotime()` function internally.
9
 *
10
 * @experimental
11
 *
12
 * @since 1.20.0
13
 */
14
interface DateTimeExtension
15
{
16
    /**
17
     * Get a DateTime object between January 1, 1970, and `$until` (defaults to "now").
18
     *
19
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
20
     * @param string|null          $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
21
     *
22
     * @see \DateTimeZone
23
     * @see http://php.net/manual/en/timezones.php
24
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
25
     *
26
     * @example DateTime('2005-08-16 20:39:21')
27
     */
28
    public function dateTime($until = 'now', string $timezone = null): \DateTime;
29
 
30
    /**
31
     * Get a DateTime object for a date between January 1, 0001, and now.
32
     *
33
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
34
     * @param string|null          $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
35
     *
36
     * @example DateTime('1265-03-22 21:15:52')
37
     *
38
     * @see http://php.net/manual/en/timezones.php
39
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
40
     */
41
    public function dateTimeAD($until = 'now', string $timezone = null): \DateTime;
42
 
43
    /**
44
     * Get a DateTime object a random date between `$from` and `$until`.
45
     * Accepts date strings that can be recognized by `strtotime()`.
46
     *
47
     * @param \DateTime|string     $from     defaults to 30 years ago
48
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
49
     * @param string|null          $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
50
     *
51
     * @see \DateTimeZone
52
     * @see http://php.net/manual/en/timezones.php
53
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
54
     */
55
    public function dateTimeBetween($from = '-30 years', $until = 'now', string $timezone = null): \DateTime;
56
 
57
    /**
58
     * Get a DateTime object based on a random date between `$from` and an interval.
59
     * Accepts date string that can be recognized by `strtotime()`.
60
     *
61
     * @param \DateTime|int|string $from     defaults to 30 years ago
62
     * @param string               $interval defaults to 5 days after
63
     * @param string|null          $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
64
     *
65
     * @see \DateTimeZone
66
     * @see http://php.net/manual/en/timezones.php
67
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
68
     */
69
    public function dateTimeInInterval($from = '-30 years', string $interval = '+5 days', string $timezone = null): \DateTime;
70
 
71
    /**
72
     * Get a date time object somewhere inside the current week.
73
     *
74
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
75
     * @param string|null          $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
76
     *
77
     * @see \DateTimeZone
78
     * @see http://php.net/manual/en/timezones.php
79
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
80
     */
81
    public function dateTimeThisWeek($until = 'now', string $timezone = null): \DateTime;
82
 
83
    /**
84
     * Get a date time object somewhere inside the current month.
85
     *
86
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
87
     * @param string|null          $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
88
     *
89
     * @see \DateTimeZone
90
     * @see http://php.net/manual/en/timezones.php
91
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
92
     */
93
    public function dateTimeThisMonth($until = 'now', string $timezone = null): \DateTime;
94
 
95
    /**
96
     * Get a date time object somewhere inside the current year.
97
     *
98
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
99
     * @param string|null          $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
100
     *
101
     * @see \DateTimeZone
102
     * @see http://php.net/manual/en/timezones.php
103
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
104
     */
105
    public function dateTimeThisYear($until = 'now', string $timezone = null): \DateTime;
106
 
107
    /**
108
     * Get a date time object somewhere inside the current decade.
109
     *
110
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
111
     * @param string|null          $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
112
     *
113
     * @see \DateTimeZone
114
     * @see http://php.net/manual/en/timezones.php
115
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
116
     */
117
    public function dateTimeThisDecade($until = 'now', string $timezone = null): \DateTime;
118
 
119
    /**
120
     * Get a date time object somewhere inside the current century.
121
     *
122
     * @param \DateTime|int|string $until    maximum timestamp, defaults to "now"
123
     * @param string|null          $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
124
     *
125
     * @see \DateTimeZone
126
     * @see http://php.net/manual/en/timezones.php
127
     * @see http://php.net/manual/en/function.date-default-timezone-get.php
128
     */
129
    public function dateTimeThisCentury($until = 'now', string $timezone = null): \DateTime;
130
 
131
    /**
132
     * Get a date string between January 1, 1970, and `$until`.
133
     *
134
     * @param string               $format DateTime format
135
     * @param \DateTime|int|string $until  maximum timestamp, defaults to "now"
136
     *
137
     * @see https://www.php.net/manual/en/datetime.format.php
138
     */
139
    public function date(string $format = 'Y-m-d', $until = 'now'): string;
140
 
141
    /**
142
     * Get a time string (24h format by default).
143
     *
144
     * @param string               $format DateTime format
145
     * @param \DateTime|int|string $until  maximum timestamp, defaults to "now"
146
     *
147
     * @see https://www.php.net/manual/en/datetime.format.php
148
     */
149
    public function time(string $format = 'H:i:s', $until = 'now'): string;
150
 
151
    /**
152
     * Get a UNIX (POSIX-compatible) timestamp between January 1, 1970, and `$until`.
153
     *
154
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
155
     */
156
    public function unixTime($until = 'now'): int;
157
 
158
    /**
159
     * Get a date string according to the ISO-8601 standard.
160
     *
161
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
162
     */
163
    public function iso8601($until = 'now'): string;
164
 
165
    /**
166
     * Get a string containing either "am" or "pm".
167
     *
168
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
169
     *
170
     * @example 'am'
171
     */
172
    public function amPm($until = 'now'): string;
173
 
174
    /**
175
     * Get a localized random day of the month.
176
     *
177
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
178
     *
179
     * @example '16'
180
     */
181
    public function dayOfMonth($until = 'now'): string;
182
 
183
    /**
184
     * Get a localized random day of the week.
185
     *
186
     * Uses internal DateTime formatting, hence PHP's internal locale will be used (change using `setlocale()`).
187
     *
188
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
189
     *
190
     * @example 'Tuesday'
191
     *
192
     * @see setlocale
193
     * @see https://www.php.net/manual/en/function.setlocale.php Set a different output language
194
     */
195
    public function dayOfWeek($until = 'now'): string;
196
 
197
    /**
198
     * Get a random month (numbered).
199
     *
200
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
201
     *
202
     * @example '7'
203
     */
204
    public function month($until = 'now'): string;
205
 
206
    /**
207
     * Get a random month.
208
     *
209
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
210
     *
211
     * @see setlocale
212
     * @see https://www.php.net/manual/en/function.setlocale.php Set a different output language
213
     *
214
     * @example 'September'
215
     */
216
    public function monthName($until = 'now'): string;
217
 
218
    /**
219
     * Get a random year between 1970 and `$until`.
220
     *
221
     * @param \DateTime|int|string $until maximum timestamp, defaults to "now"
222
     *
223
     * @example '1987'
224
     */
225
    public function year($until = 'now'): string;
226
 
227
    /**
228
     * Get a random century, formatted as Roman numerals.
229
     *
230
     * @example 'XVII'
231
     */
232
    public function century(): string;
233
 
234
    /**
235
     * Get a random timezone, uses `\DateTimeZone::listIdentifiers()` internally.
236
     *
237
     * @param string|null $countryCode two-letter ISO 3166-1 compatible country code
238
     *
239
     * @example 'Europe/Rome'
240
     */
241
    public function timezone(string $countryCode = null): string;
242
}