Support
1 month ago
Action.php
1 month ago
Cacheable.php
1 month ago
Capability.php
1 month ago
CastAttribute.php
1 month ago
Constant.php
1 month ago
Container.php
1 month ago
Discoverable.php
1 month ago
Event.php
1 month ago
Exportable.php
1 month ago
Importable.php
1 month ago
Middleware.php
1 month ago
Migration.php
1 month ago
Parser.php
1 month ago
Registrable.php
1 month ago
Request.php
5 days ago
Response.php
1 month ago
RewriteRule.php
1 month ago
Rule.php
1 month ago
ServiceProvider.php
1 month ago
Shortcode.php
1 month ago
SomoyInterface.php
5 days ago
Uploader.php
1 month ago
SomoyInterface.php
740 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Contract for a date and time value object. |
| 5 | * |
| 6 | * Type against this instead of a concrete date class so the implementation can |
| 7 | * be replaced without touching the call sites. |
| 8 | * |
| 9 | * Extending DateTimeInterface is deliberate. The query layer branches on |
| 10 | * `instanceof DateTimeInterface` when it prepares bindings and builds date |
| 11 | * comparisons, and PHP refuses to let a plain user class implement |
| 12 | * DateTimeInterface. An implementation of this contract must therefore extend |
| 13 | * the native DateTime (or DateTimeImmutable), which is exactly the guarantee |
| 14 | * those call sites need. That also supplies format(), diff(), getTimestamp(), |
| 15 | * getTimezone() and getOffset(), so they are not redeclared here. |
| 16 | * |
| 17 | * Naming rules for implementations: |
| 18 | * |
| 19 | * - Every method declared here is snake_case. The camelCase methods inherited |
| 20 | * from the native date classes stay reachable because PHP cannot hide them, |
| 21 | * but the snake_case counterparts are the supported API. |
| 22 | * - Mutating methods are expected to change the instance in place and return |
| 23 | * `$this`, so they can be chained. Callers use copy() to keep the original. |
| 24 | * |
| 25 | * Format constants are intentionally left off this contract: PHP 7.4 forbids a |
| 26 | * class from overriding a constant it inherits from an interface, and the |
| 27 | * formatters read theirs through `static::`, which implementations are meant to |
| 28 | * be able to override. |
| 29 | * |
| 30 | * @package Framework |
| 31 | * @subpackage Contracts |
| 32 | * @since 1.0.0 |
| 33 | */ |
| 34 | namespace Kirki\Framework\Contracts; |
| 35 | |
| 36 | \defined('ABSPATH') || exit; |
| 37 | use DateTimeInterface; |
| 38 | use JsonSerializable; |
| 39 | interface SomoyInterface extends DateTimeInterface, JsonSerializable |
| 40 | { |
| 41 | /** |
| 42 | * Get an instance for the current date and time. |
| 43 | * |
| 44 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 45 | * |
| 46 | * @return static The current date and time. |
| 47 | * |
| 48 | * @since 1.0.0 |
| 49 | */ |
| 50 | public static function now($timezone = null); |
| 51 | /** |
| 52 | * Get an instance for today at midnight. |
| 53 | * |
| 54 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 55 | * |
| 56 | * @return static Today at midnight. |
| 57 | * |
| 58 | * @since 1.0.0 |
| 59 | */ |
| 60 | public static function today($timezone = null); |
| 61 | /** |
| 62 | * Get an instance for yesterday at midnight. |
| 63 | * |
| 64 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 65 | * |
| 66 | * @return static Yesterday at midnight. |
| 67 | * |
| 68 | * @since 1.0.0 |
| 69 | */ |
| 70 | public static function yesterday($timezone = null); |
| 71 | /** |
| 72 | * Get an instance for tomorrow at midnight. |
| 73 | * |
| 74 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 75 | * |
| 76 | * @return static Tomorrow at midnight. |
| 77 | * |
| 78 | * @since 1.0.0 |
| 79 | */ |
| 80 | public static function tomorrow($timezone = null); |
| 81 | /** |
| 82 | * Parse a value into a date instance. |
| 83 | * |
| 84 | * Integers and floats are read as unix timestamps. Null and empty strings |
| 85 | * resolve to the current date and time. |
| 86 | * |
| 87 | * @param DateTimeInterface|string|int|float|null $time The value to parse. |
| 88 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 89 | * |
| 90 | * @return static The parsed date. |
| 91 | * |
| 92 | * @throws \Framework\Exceptions\InvalidDateFormatException When the value cannot be parsed. |
| 93 | * |
| 94 | * @since 1.0.0 |
| 95 | */ |
| 96 | public static function parse($time = null, $timezone = null); |
| 97 | /** |
| 98 | * Create an instance from any other date object, preserving the |
| 99 | * microseconds and the timezone. |
| 100 | * |
| 101 | * @param DateTimeInterface $date The date to copy. |
| 102 | * |
| 103 | * @return static The new instance. |
| 104 | * |
| 105 | * @since 1.0.0 |
| 106 | */ |
| 107 | public static function instance(DateTimeInterface $date); |
| 108 | /** |
| 109 | * Create an instance from a unix timestamp. |
| 110 | * |
| 111 | * A timestamp without an explicit timezone is expressed in the default |
| 112 | * timezone rather than in UTC. |
| 113 | * |
| 114 | * @param int|float|string $timestamp The unix timestamp. |
| 115 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 116 | * |
| 117 | * @return static The new instance. |
| 118 | * |
| 119 | * @throws \Framework\Exceptions\InvalidDateFormatException When the timestamp is not numeric. |
| 120 | * |
| 121 | * @since 1.0.0 |
| 122 | */ |
| 123 | public static function create_from_timestamp($timestamp, $timezone = null); |
| 124 | /** |
| 125 | * Create an instance from a value matching the given format. |
| 126 | * |
| 127 | * @param string $format The format the value is written in. |
| 128 | * @param string $time The value to read. |
| 129 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 130 | * |
| 131 | * @return static The new instance. |
| 132 | * |
| 133 | * @throws \Framework\Exceptions\InvalidDateFormatException When the value does not match the format. |
| 134 | * |
| 135 | * @since 1.0.0 |
| 136 | */ |
| 137 | public static function create_from_format($format, $time, $timezone = null); |
| 138 | /** |
| 139 | * Create an instance from the given date and time parts. |
| 140 | * |
| 141 | * Any part left as null falls back to the matching part of the current |
| 142 | * date and time. |
| 143 | * |
| 144 | * @param int|null $year The year. |
| 145 | * @param int|null $month The month. |
| 146 | * @param int|null $day The day. |
| 147 | * @param int|null $hour The hour. |
| 148 | * @param int|null $minute The minute. |
| 149 | * @param int|null $second The second. |
| 150 | * @param \DateTimeZone|string|null $timezone The timezone to use. |
| 151 | * |
| 152 | * @return static The new instance. |
| 153 | * |
| 154 | * @since 1.0.0 |
| 155 | */ |
| 156 | public static function create($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null); |
| 157 | /** |
| 158 | * Check if the value is a valid date. |
| 159 | * |
| 160 | * Must not raise for any input type, including arrays and objects. |
| 161 | * |
| 162 | * @param mixed $value The value to check. |
| 163 | * |
| 164 | * @return bool Whether the value can be read as a date. |
| 165 | * |
| 166 | * @since 1.0.0 |
| 167 | */ |
| 168 | public static function is_valid_date($value); |
| 169 | /** |
| 170 | * Get a copy of the instance. |
| 171 | * |
| 172 | * @return static The copied instance. |
| 173 | * |
| 174 | * @since 1.0.0 |
| 175 | */ |
| 176 | public function copy(); |
| 177 | /** |
| 178 | * Add the given number of seconds. |
| 179 | * |
| 180 | * @param int $value The number of seconds. |
| 181 | * |
| 182 | * @return $this The mutated instance. |
| 183 | * |
| 184 | * @since 1.0.0 |
| 185 | */ |
| 186 | public function add_seconds($value = 1); |
| 187 | /** |
| 188 | * Add the given number of minutes. |
| 189 | * |
| 190 | * @param int $value The number of minutes. |
| 191 | * |
| 192 | * @return $this The mutated instance. |
| 193 | * |
| 194 | * @since 1.0.0 |
| 195 | */ |
| 196 | public function add_minutes($value = 1); |
| 197 | /** |
| 198 | * Add the given number of hours. |
| 199 | * |
| 200 | * @param int $value The number of hours. |
| 201 | * |
| 202 | * @return $this The mutated instance. |
| 203 | * |
| 204 | * @since 1.0.0 |
| 205 | */ |
| 206 | public function add_hours($value = 1); |
| 207 | /** |
| 208 | * Add the given number of days. |
| 209 | * |
| 210 | * @param int $value The number of days. |
| 211 | * |
| 212 | * @return $this The mutated instance. |
| 213 | * |
| 214 | * @since 1.0.0 |
| 215 | */ |
| 216 | public function add_days($value = 1); |
| 217 | /** |
| 218 | * Add the given number of weeks. |
| 219 | * |
| 220 | * @param int $value The number of weeks. |
| 221 | * |
| 222 | * @return $this The mutated instance. |
| 223 | * |
| 224 | * @since 1.0.0 |
| 225 | */ |
| 226 | public function add_weeks($value = 1); |
| 227 | /** |
| 228 | * Add the given number of months. |
| 229 | * |
| 230 | * Expected to overflow into the next month when the resulting month is |
| 231 | * shorter, matching the native date arithmetic. |
| 232 | * |
| 233 | * @param int $value The number of months. |
| 234 | * |
| 235 | * @return $this The mutated instance. |
| 236 | * |
| 237 | * @since 1.0.0 |
| 238 | */ |
| 239 | public function add_months($value = 1); |
| 240 | /** |
| 241 | * Add the given number of years. |
| 242 | * |
| 243 | * @param int $value The number of years. |
| 244 | * |
| 245 | * @return $this The mutated instance. |
| 246 | * |
| 247 | * @since 1.0.0 |
| 248 | */ |
| 249 | public function add_years($value = 1); |
| 250 | /** |
| 251 | * Subtract the given number of seconds. |
| 252 | * |
| 253 | * @param int $value The number of seconds. |
| 254 | * |
| 255 | * @return $this The mutated instance. |
| 256 | * |
| 257 | * @since 1.0.0 |
| 258 | */ |
| 259 | public function sub_seconds($value = 1); |
| 260 | /** |
| 261 | * Subtract the given number of minutes. |
| 262 | * |
| 263 | * @param int $value The number of minutes. |
| 264 | * |
| 265 | * @return $this The mutated instance. |
| 266 | * |
| 267 | * @since 1.0.0 |
| 268 | */ |
| 269 | public function sub_minutes($value = 1); |
| 270 | /** |
| 271 | * Subtract the given number of hours. |
| 272 | * |
| 273 | * @param int $value The number of hours. |
| 274 | * |
| 275 | * @return $this The mutated instance. |
| 276 | * |
| 277 | * @since 1.0.0 |
| 278 | */ |
| 279 | public function sub_hours($value = 1); |
| 280 | /** |
| 281 | * Subtract the given number of days. |
| 282 | * |
| 283 | * @param int $value The number of days. |
| 284 | * |
| 285 | * @return $this The mutated instance. |
| 286 | * |
| 287 | * @since 1.0.0 |
| 288 | */ |
| 289 | public function sub_days($value = 1); |
| 290 | /** |
| 291 | * Subtract the given number of weeks. |
| 292 | * |
| 293 | * @param int $value The number of weeks. |
| 294 | * |
| 295 | * @return $this The mutated instance. |
| 296 | * |
| 297 | * @since 1.0.0 |
| 298 | */ |
| 299 | public function sub_weeks($value = 1); |
| 300 | /** |
| 301 | * Subtract the given number of months. |
| 302 | * |
| 303 | * @param int $value The number of months. |
| 304 | * |
| 305 | * @return $this The mutated instance. |
| 306 | * |
| 307 | * @since 1.0.0 |
| 308 | */ |
| 309 | public function sub_months($value = 1); |
| 310 | /** |
| 311 | * Subtract the given number of years. |
| 312 | * |
| 313 | * @param int $value The number of years. |
| 314 | * |
| 315 | * @return $this The mutated instance. |
| 316 | * |
| 317 | * @since 1.0.0 |
| 318 | */ |
| 319 | public function sub_years($value = 1); |
| 320 | /** |
| 321 | * Add a single second. |
| 322 | * |
| 323 | * @return $this The mutated instance. |
| 324 | * |
| 325 | * @since 1.0.0 |
| 326 | */ |
| 327 | public function add_second(); |
| 328 | /** |
| 329 | * Add a single minute. |
| 330 | * |
| 331 | * @return $this The mutated instance. |
| 332 | * |
| 333 | * @since 1.0.0 |
| 334 | */ |
| 335 | public function add_minute(); |
| 336 | /** |
| 337 | * Add a single hour. |
| 338 | * |
| 339 | * @return $this The mutated instance. |
| 340 | * |
| 341 | * @since 1.0.0 |
| 342 | */ |
| 343 | public function add_hour(); |
| 344 | /** |
| 345 | * Add a single day. |
| 346 | * |
| 347 | * @return $this The mutated instance. |
| 348 | * |
| 349 | * @since 1.0.0 |
| 350 | */ |
| 351 | public function add_day(); |
| 352 | /** |
| 353 | * Add a single week. |
| 354 | * |
| 355 | * @return $this The mutated instance. |
| 356 | * |
| 357 | * @since 1.0.0 |
| 358 | */ |
| 359 | public function add_week(); |
| 360 | /** |
| 361 | * Add a single month. |
| 362 | * |
| 363 | * @return $this The mutated instance. |
| 364 | * |
| 365 | * @since 1.0.0 |
| 366 | */ |
| 367 | public function add_month(); |
| 368 | /** |
| 369 | * Add a single year. |
| 370 | * |
| 371 | * @return $this The mutated instance. |
| 372 | * |
| 373 | * @since 1.0.0 |
| 374 | */ |
| 375 | public function add_year(); |
| 376 | /** |
| 377 | * Subtract a single second. |
| 378 | * |
| 379 | * @return $this The mutated instance. |
| 380 | * |
| 381 | * @since 1.0.0 |
| 382 | */ |
| 383 | public function sub_second(); |
| 384 | /** |
| 385 | * Subtract a single minute. |
| 386 | * |
| 387 | * @return $this The mutated instance. |
| 388 | * |
| 389 | * @since 1.0.0 |
| 390 | */ |
| 391 | public function sub_minute(); |
| 392 | /** |
| 393 | * Subtract a single hour. |
| 394 | * |
| 395 | * @return $this The mutated instance. |
| 396 | * |
| 397 | * @since 1.0.0 |
| 398 | */ |
| 399 | public function sub_hour(); |
| 400 | /** |
| 401 | * Subtract a single day. |
| 402 | * |
| 403 | * @return $this The mutated instance. |
| 404 | * |
| 405 | * @since 1.0.0 |
| 406 | */ |
| 407 | public function sub_day(); |
| 408 | /** |
| 409 | * Subtract a single week. |
| 410 | * |
| 411 | * @return $this The mutated instance. |
| 412 | * |
| 413 | * @since 1.0.0 |
| 414 | */ |
| 415 | public function sub_week(); |
| 416 | /** |
| 417 | * Subtract a single month. |
| 418 | * |
| 419 | * @return $this The mutated instance. |
| 420 | * |
| 421 | * @since 1.0.0 |
| 422 | */ |
| 423 | public function sub_month(); |
| 424 | /** |
| 425 | * Subtract a single year. |
| 426 | * |
| 427 | * @return $this The mutated instance. |
| 428 | * |
| 429 | * @since 1.0.0 |
| 430 | */ |
| 431 | public function sub_year(); |
| 432 | /** |
| 433 | * Move the instance to the first moment of its day. |
| 434 | * |
| 435 | * @return $this The mutated instance. |
| 436 | * |
| 437 | * @since 1.0.0 |
| 438 | */ |
| 439 | public function start_of_day(); |
| 440 | /** |
| 441 | * Move the instance to the last moment of its day. |
| 442 | * |
| 443 | * @return $this The mutated instance. |
| 444 | * |
| 445 | * @since 1.0.0 |
| 446 | */ |
| 447 | public function end_of_day(); |
| 448 | /** |
| 449 | * Move the instance to the first moment of its week, weeks starting on Monday. |
| 450 | * |
| 451 | * @return $this The mutated instance. |
| 452 | * |
| 453 | * @since 1.0.0 |
| 454 | */ |
| 455 | public function start_of_week(); |
| 456 | /** |
| 457 | * Move the instance to the last moment of its week, weeks ending on Sunday. |
| 458 | * |
| 459 | * @return $this The mutated instance. |
| 460 | * |
| 461 | * @since 1.0.0 |
| 462 | */ |
| 463 | public function end_of_week(); |
| 464 | /** |
| 465 | * Move the instance to the first moment of its month. |
| 466 | * |
| 467 | * @return $this The mutated instance. |
| 468 | * |
| 469 | * @since 1.0.0 |
| 470 | */ |
| 471 | public function start_of_month(); |
| 472 | /** |
| 473 | * Move the instance to the last moment of its month. |
| 474 | * |
| 475 | * @return $this The mutated instance. |
| 476 | * |
| 477 | * @since 1.0.0 |
| 478 | */ |
| 479 | public function end_of_month(); |
| 480 | /** |
| 481 | * Move the instance to the first moment of its year. |
| 482 | * |
| 483 | * @return $this The mutated instance. |
| 484 | * |
| 485 | * @since 1.0.0 |
| 486 | */ |
| 487 | public function start_of_year(); |
| 488 | /** |
| 489 | * Move the instance to the last moment of its year. |
| 490 | * |
| 491 | * @return $this The mutated instance. |
| 492 | * |
| 493 | * @since 1.0.0 |
| 494 | */ |
| 495 | public function end_of_year(); |
| 496 | /** |
| 497 | * Move the instance to the first day of its month at midnight. |
| 498 | * |
| 499 | * @return $this The mutated instance. |
| 500 | * |
| 501 | * @since 1.0.0 |
| 502 | */ |
| 503 | public function first_of_month(); |
| 504 | /** |
| 505 | * Move the instance to the last day of its month at midnight. |
| 506 | * |
| 507 | * @return $this The mutated instance. |
| 508 | * |
| 509 | * @since 1.0.0 |
| 510 | */ |
| 511 | public function last_of_month(); |
| 512 | /** |
| 513 | * Determine whether the instance is equal to the given date. |
| 514 | * |
| 515 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 516 | * |
| 517 | * @return bool True when both represent the same moment. |
| 518 | * |
| 519 | * @since 1.0.0 |
| 520 | */ |
| 521 | public function eq($date); |
| 522 | /** |
| 523 | * Determine whether the instance is different from the given date. |
| 524 | * |
| 525 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 526 | * |
| 527 | * @return bool True when both represent a different moment. |
| 528 | * |
| 529 | * @since 1.0.0 |
| 530 | */ |
| 531 | public function ne($date); |
| 532 | /** |
| 533 | * Determine whether the instance is later than the given date. |
| 534 | * |
| 535 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 536 | * |
| 537 | * @return bool True when the instance is later. |
| 538 | * |
| 539 | * @since 1.0.0 |
| 540 | */ |
| 541 | public function gt($date); |
| 542 | /** |
| 543 | * Determine whether the instance is later than or equal to the given date. |
| 544 | * |
| 545 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 546 | * |
| 547 | * @return bool True when the instance is later or equal. |
| 548 | * |
| 549 | * @since 1.0.0 |
| 550 | */ |
| 551 | public function gte($date); |
| 552 | /** |
| 553 | * Determine whether the instance is earlier than the given date. |
| 554 | * |
| 555 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 556 | * |
| 557 | * @return bool True when the instance is earlier. |
| 558 | * |
| 559 | * @since 1.0.0 |
| 560 | */ |
| 561 | public function lt($date); |
| 562 | /** |
| 563 | * Determine whether the instance is earlier than or equal to the given date. |
| 564 | * |
| 565 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 566 | * |
| 567 | * @return bool True when the instance is earlier or equal. |
| 568 | * |
| 569 | * @since 1.0.0 |
| 570 | */ |
| 571 | public function lte($date); |
| 572 | /** |
| 573 | * Determine whether the instance is later than the given date. |
| 574 | * |
| 575 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 576 | * |
| 577 | * @return bool True when the instance is later. |
| 578 | * |
| 579 | * @since 1.0.0 |
| 580 | */ |
| 581 | public function is_after($date); |
| 582 | /** |
| 583 | * Determine whether the instance is earlier than the given date. |
| 584 | * |
| 585 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 586 | * |
| 587 | * @return bool True when the instance is earlier. |
| 588 | * |
| 589 | * @since 1.0.0 |
| 590 | */ |
| 591 | public function is_before($date); |
| 592 | /** |
| 593 | * Determine whether the instance falls on the same day as the given date. |
| 594 | * |
| 595 | * @param DateTimeInterface|string|int|float|null $date The date to compare with. |
| 596 | * |
| 597 | * @return bool True when both fall on the same calendar day. |
| 598 | * |
| 599 | * @since 1.0.0 |
| 600 | */ |
| 601 | public function is_same_day($date); |
| 602 | /** |
| 603 | * Determine whether the instance falls between the given dates, bounds included. |
| 604 | * |
| 605 | * @param DateTimeInterface|string|int|float|null $start The lower bound. |
| 606 | * @param DateTimeInterface|string|int|float|null $end The upper bound. |
| 607 | * |
| 608 | * @return bool True when the instance falls within the range. |
| 609 | * |
| 610 | * @since 1.0.0 |
| 611 | */ |
| 612 | public function between($start, $end); |
| 613 | /** |
| 614 | * Format the instance as a date. |
| 615 | * |
| 616 | * @return string The formatted date. |
| 617 | * |
| 618 | * @since 1.0.0 |
| 619 | */ |
| 620 | public function to_date_string(); |
| 621 | /** |
| 622 | * Format the instance as a time. |
| 623 | * |
| 624 | * @return string The formatted time. |
| 625 | * |
| 626 | * @since 1.0.0 |
| 627 | */ |
| 628 | public function to_time_string(); |
| 629 | /** |
| 630 | * Format the instance as a date and time. |
| 631 | * |
| 632 | * @return string The formatted date and time. |
| 633 | * |
| 634 | * @since 1.0.0 |
| 635 | */ |
| 636 | public function to_date_time_string(); |
| 637 | /** |
| 638 | * Format the instance as an ISO-8601 string keeping the timezone offset. |
| 639 | * |
| 640 | * @return string The formatted date and time. |
| 641 | * |
| 642 | * @since 1.0.0 |
| 643 | */ |
| 644 | public function to_iso8601_string(); |
| 645 | /** |
| 646 | * Format the instance the way it is serialized to JSON. |
| 647 | * |
| 648 | * Expected to be normalized to UTC and to carry a trailing "Z", because |
| 649 | * this is the shape API consumers already receive. |
| 650 | * |
| 651 | * @return string The formatted date and time. |
| 652 | * |
| 653 | * @since 1.0.0 |
| 654 | */ |
| 655 | public function to_json(); |
| 656 | /** |
| 657 | * Format the instance as a SQL safe date string. |
| 658 | * |
| 659 | * @return string The formatted date and time. |
| 660 | * |
| 661 | * @since 1.0.0 |
| 662 | */ |
| 663 | public function to_sql_datetime_string(); |
| 664 | /** |
| 665 | * Get the unix timestamp of the instance. |
| 666 | * |
| 667 | * @return int The unix timestamp. |
| 668 | * |
| 669 | * @since 1.0.0 |
| 670 | */ |
| 671 | public function get_timestamp(); |
| 672 | /** |
| 673 | * Get the timezone of the instance. |
| 674 | * |
| 675 | * @return \DateTimeZone The timezone. |
| 676 | * |
| 677 | * @since 1.0.0 |
| 678 | */ |
| 679 | public function get_timezone(); |
| 680 | /** |
| 681 | * Move the instance to the given timezone, keeping the same moment in time. |
| 682 | * |
| 683 | * @param \DateTimeZone|string $timezone The timezone to move to. |
| 684 | * |
| 685 | * @return $this The mutated instance. |
| 686 | * |
| 687 | * @since 1.0.0 |
| 688 | */ |
| 689 | public function set_timezone($timezone); |
| 690 | /** |
| 691 | * Set the date part of the instance. |
| 692 | * |
| 693 | * @param int $year The year. |
| 694 | * @param int $month The month. |
| 695 | * @param int $day The day. |
| 696 | * |
| 697 | * @return $this The mutated instance. |
| 698 | * |
| 699 | * @since 1.0.0 |
| 700 | */ |
| 701 | public function set_date($year, $month, $day); |
| 702 | /** |
| 703 | * Set the time part of the instance. |
| 704 | * |
| 705 | * @param int $hour The hour. |
| 706 | * @param int $minute The minute. |
| 707 | * @param int $second The second. |
| 708 | * @param int $microsecond The microsecond. |
| 709 | * |
| 710 | * @return $this The mutated instance. |
| 711 | * |
| 712 | * @since 1.0.0 |
| 713 | */ |
| 714 | public function set_time($hour, $minute, $second = 0, $microsecond = 0); |
| 715 | /** |
| 716 | * Set the time part of the instance from a time string. |
| 717 | * |
| 718 | * Accepts the shapes a time column holds, such as "10", "10:30", |
| 719 | * "10:30:45" and "10:30:45.123456". Parts that are not given are reset to |
| 720 | * zero and the date part is left untouched. |
| 721 | * |
| 722 | * @param string $time The time to read. |
| 723 | * |
| 724 | * @return $this The mutated instance. |
| 725 | * |
| 726 | * @throws \Framework\Exceptions\InvalidDateFormatException When the time cannot be read. |
| 727 | * |
| 728 | * @since 1.0.0 |
| 729 | */ |
| 730 | public function set_time_from_time_string($time); |
| 731 | /** |
| 732 | * Get the value used when the instance is cast to a string. |
| 733 | * |
| 734 | * @return string The string representation. |
| 735 | * |
| 736 | * @since 1.0.0 |
| 737 | */ |
| 738 | public function __toString(); |
| 739 | } |
| 740 |