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