├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── src ├── Duration.php ├── Iso8601 │ ├── Iso8601Date.php │ ├── Iso8601DateTime.php │ ├── Iso8601Duration.php │ ├── Iso8601Time.php │ └── Iso8601Weekday.php ├── Temporal.php ├── Throwable │ ├── Error.php │ ├── Exception.php │ ├── IllegalDurationOperationError.php │ ├── InvalidDateTimeFormatError.php │ ├── InvalidDurationComponentError.php │ ├── InvalidDurationFormatError.php │ └── InvalidTimeZoneIdentifierError.php └── Timestamp │ └── Unix.php └── tests └── index.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = tab 7 | trim_trailing_whitespace = true 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | indent_style = space 13 | indent_size = 4 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ 2 | .idea/ 3 | 4 | # Composer 5 | vendor/ 6 | composer.phar 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) delight.im (https://www.delight.im/) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP-Temporal 2 | 3 | Immutable date and time for PHP with a convenient interface 4 | 5 | ## Requirements 6 | 7 | * PHP 5.6.0+ 8 | 9 | ## Installation 10 | 11 | 1. Include the library via Composer [[?]](https://github.com/delight-im/Knowledge/blob/master/Composer%20(PHP).md): 12 | 13 | ``` 14 | $ composer require delight-im/temporal 15 | ``` 16 | 17 | 1. Include the Composer autoloader: 18 | 19 | ```php 20 | require __DIR__ . '/vendor/autoload.php'; 21 | ``` 22 | 23 | 1. Make sure to set your default time zone in PHP, e.g.: 24 | 25 | ```php 26 | \date_default_timezone_set('America/Los_Angeles'); 27 | ``` 28 | 29 | ## Usage 30 | 31 | * [Creating instances and parsing dates and time](#creating-instances-and-parsing-dates-and-time) 32 | * [Adding and subtracting date and time](#adding-and-subtracting-date-and-time) 33 | * [Fetching individual components or units of date and time](#fetching-individual-components-or-units-of-date-and-time) 34 | * [Modifying individual components or units of date and time](#modifying-individual-components-or-units-of-date-and-time) 35 | * [Skipping to boundaries of date and time units](#skipping-to-boundaries-of-date-and-time-units) 36 | * [Formatting and outputting date and time](#formatting-and-outputting-date-and-time) 37 | * [Fetching decades, centuries and millennia from dates](#fetching-decades-centuries-and-millennia-from-dates) 38 | * [Checking for daylight saving time (DST)](#checking-for-daylight-saving-time-dst) 39 | * [Checking for leap years](#checking-for-leap-years) 40 | * [Checking for special dates](#checking-for-special-dates) 41 | * [Calculating differences between two instances of date and time](#calculating-differences-between-two-instances-of-date-and-time) 42 | * [Reading and writing durations of date and time](#reading-and-writing-durations-of-date-and-time) 43 | * [Comparing instances of date and time with each other](#comparing-instances-of-date-and-time-with-each-other) 44 | * [Equality](#equality) 45 | * [Less than](#less-than) 46 | * [Greater than](#greater-than) 47 | * [Less than or equal to](#less-than-or-equal-to) 48 | * [Greater than or equal to](#greater-than-or-equal-to) 49 | * [Checking whether dates and times are in the past or future](#checking-whether-dates-and-times-are-in-the-past-or-future) 50 | * [Changing and converting timezones](#changing-and-converting-timezones) 51 | 52 | ### Creating instances and parsing dates and time 53 | 54 | ```php 55 | $dateTime = \Delight\Temporal\Temporal::now(); 56 | // or 57 | $dateTime = \Delight\Temporal\Temporal::now('Asia/Tokyo'); 58 | 59 | // or 60 | 61 | $dateTime = \Delight\Temporal\Temporal::fromUnixSeconds(-14182916); 62 | // or 63 | $dateTime = \Delight\Temporal\Temporal::fromUnixSeconds(-14182916, 'America/Los_Angeles'); 64 | 65 | // or 66 | 67 | $dateTime = \Delight\Temporal\Temporal::fromUnixMillis(-14182916000); 68 | // or 69 | $dateTime = \Delight\Temporal\Temporal::fromUnixMillis(-14182916000, 'Asia/Tokyo'); 70 | 71 | // or 72 | 73 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateTimeExtended('1969-07-20T20:18:04+00:00'); 74 | // or 75 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateTimeExtended('1969-07-20T20:18:04Z', 'America/Los_Angeles'); 76 | // or 77 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateTimeBasic('19690720T201804Z'); 78 | // or 79 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateTimeBasic('19690720T201804+0000', 'Asia/Tokyo'); 80 | 81 | // or 82 | 83 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateExtended('1969-07-20'); 84 | // or 85 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateExtended('1969-07-20', 'America/Los_Angeles'); 86 | // or 87 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateBasic('19690720'); 88 | // or 89 | $dateTime = \Delight\Temporal\Temporal::fromIso8601DateBasic('19690720', 'Asia/Tokyo'); 90 | 91 | // or 92 | 93 | $dateTime = \Delight\Temporal\Temporal::fromIso8601TimeExtended('20:18:04Z'); 94 | // or 95 | $dateTime = \Delight\Temporal\Temporal::fromIso8601TimeExtended('20:18:04+00:00', 'America/Los_Angeles'); 96 | // or 97 | $dateTime = \Delight\Temporal\Temporal::fromIso8601TimeBasic('201804+0000'); 98 | // or 99 | $dateTime = \Delight\Temporal\Temporal::fromIso8601TimeBasic('201804Z', 'Asia/Tokyo'); 100 | 101 | // or 102 | 103 | $dateTime = \Delight\Temporal\Temporal::fromDateTime(1969, 7, 20, 20, 18, 4); 104 | // or 105 | $dateTime = \Delight\Temporal\Temporal::fromDateTime(1969, 7, 20, 20, 18, 4, 'America/Los_Angeles'); 106 | 107 | // or 108 | 109 | $dateTime = \Delight\Temporal\Temporal::fromDate(1969, 7, 20); 110 | // or 111 | $dateTime = \Delight\Temporal\Temporal::fromDate(1969, 7, 20, 'Asia/Tokyo'); 112 | 113 | // or 114 | 115 | $dateTime = \Delight\Temporal\Temporal::fromTime(20, 18, 4); 116 | // or 117 | $dateTime = \Delight\Temporal\Temporal::fromTime(20, 18, 4, 'America/Los_Angeles'); 118 | 119 | // or 120 | 121 | $dateTime = \Delight\Temporal\Temporal::fromFormat('20.07.1969', 'd.m.Y'); 122 | // or 123 | $dateTime = \Delight\Temporal\Temporal::fromFormat('20.07.1969', 'd.m.Y', 'Asia/Tokyo'); 124 | 125 | // or 126 | 127 | $dateTime = \Delight\Temporal\Temporal::fromDateTimeInterface(new \DateTime()); 128 | // or 129 | $dateTime = \Delight\Temporal\Temporal::fromDateTimeInterface(new \DateTimeImmutable()); 130 | 131 | // or 132 | 133 | $dateTime = \Delight\Temporal\Temporal::yesterday(); 134 | // or 135 | $dateTime = \Delight\Temporal\Temporal::yesterday('America/Los_Angeles'); 136 | 137 | // or 138 | 139 | $dateTime = \Delight\Temporal\Temporal::tomorrow(); 140 | // or 141 | $dateTime = \Delight\Temporal\Temporal::tomorrow('America/Los_Angeles'); 142 | ``` 143 | 144 | ### Adding and subtracting date and time 145 | 146 | ```php 147 | $dateTime = $dateTime->plusYears(7); 148 | // or 149 | $dateTime = $dateTime->minusYears(4); 150 | 151 | // or 152 | 153 | $dateTime = $dateTime->plusMonths(30); 154 | // or 155 | $dateTime = $dateTime->minusMonths(8); 156 | 157 | // or 158 | 159 | $dateTime = $dateTime->plusWeeks(6); 160 | // or 161 | $dateTime = $dateTime->minusWeeks(2); 162 | 163 | // or 164 | 165 | $dateTime = $dateTime->plusDays(28); 166 | // or 167 | $dateTime = $dateTime->minusDays(100); 168 | 169 | // or 170 | 171 | $dateTime = $dateTime->plusHours(36); 172 | // or 173 | $dateTime = $dateTime->minusHours(19); 174 | 175 | // or 176 | 177 | $dateTime = $dateTime->plusMinutes(90); 178 | // or 179 | $dateTime = $dateTime->minusMinutes(47); 180 | 181 | // or 182 | 183 | $dateTime = $dateTime->plusSeconds(30); 184 | // or 185 | $dateTime = $dateTime->minusSeconds(125); 186 | 187 | // or 188 | 189 | $dateTime = $dateTime->plusDuration('P3Y6M4DT12H30M5S'); 190 | // or 191 | $dateTime = $dateTime->minusDuration('P3Y6M4DT12H30M5S'); 192 | 193 | // or 194 | 195 | $dateTime = $dateTime->plusMonths(6)->plusWeeks(2)->minusDays(3); 196 | ``` 197 | 198 | ### Fetching individual components or units of date and time 199 | 200 | ```php 201 | $dateTime->getYear(); 202 | // or 203 | $dateTime->getMonth(); 204 | // or 205 | $dateTime->getDay(); 206 | // or 207 | $dateTime->getHour(); 208 | // or 209 | $dateTime->getMinute(); 210 | // or 211 | $dateTime->getSecond(); 212 | 213 | // or 214 | 215 | $dateTime->getWeekday(); 216 | 217 | // or 218 | 219 | $dateTime->isMonday(); 220 | // or 221 | $dateTime->isTuesday(); 222 | // or 223 | $dateTime->isWednesday(); 224 | // or 225 | $dateTime->isThursday(); 226 | // or 227 | $dateTime->isFriday(); 228 | // or 229 | $dateTime->isSaturday(); 230 | // or 231 | $dateTime->isSunday(); 232 | 233 | // or 234 | 235 | $dateTime->getWeekOfYear(); 236 | // or 237 | $dateTime->getWeekYear(); 238 | // or 239 | $dateTime->getDayOfYear(); 240 | ``` 241 | 242 | ### Modifying individual components or units of date and time 243 | 244 | ```php 245 | $dateTime = $dateTime->withYear(1969); 246 | // or 247 | $dateTime = $dateTime->withMonth(7); 248 | // or 249 | $dateTime = $dateTime->withDay(20); 250 | // or 251 | $dateTime = $dateTime->withHour(20); 252 | // or 253 | $dateTime = $dateTime->withMinute(18); 254 | // or 255 | $dateTime = $dateTime->withSecond(4); 256 | 257 | // or 258 | 259 | $dateTime = $dateTime->withDate(1969, 7, 20); 260 | // or 261 | $dateTime = $dateTime->withTime(20, 18, 4); 262 | 263 | // or 264 | 265 | $dateTime = $dateTime->withDate(1969, 7, 20)->withMinute(0)->withSecond(0); 266 | ``` 267 | 268 | ### Skipping to boundaries of date and time units 269 | 270 | ```php 271 | $dateTime = $dateTime->startOfMinute(); 272 | // or 273 | $dateTime = $dateTime->endOfMinute(); 274 | 275 | // or 276 | 277 | $dateTime = $dateTime->startOfHour(); 278 | // or 279 | $dateTime = $dateTime->endOfHour(); 280 | 281 | // or 282 | 283 | $dateTime = $dateTime->startOfDay(); 284 | // or 285 | $dateTime = $dateTime->endOfDay(); 286 | 287 | // or 288 | 289 | $dateTime = $dateTime->startOfWeek(); 290 | // or 291 | $dateTime = $dateTime->endOfWeek(); 292 | 293 | // or 294 | 295 | $dateTime = $dateTime->startOfMonth(); 296 | // or 297 | $dateTime = $dateTime->endOfMonth(); 298 | 299 | // or 300 | 301 | $dateTime = $dateTime->startOfYear(); 302 | // or 303 | $dateTime = $dateTime->endOfYear(); 304 | 305 | // or 306 | 307 | $dateTime = $dateTime->startOfDecade(); 308 | // or 309 | $dateTime = $dateTime->endOfDecade(); 310 | 311 | // or 312 | 313 | $dateTime = $dateTime->startOfCentury(); 314 | // or 315 | $dateTime = $dateTime->endOfCentury(); 316 | 317 | // or 318 | 319 | $dateTime = $dateTime->startOfMillennium(); 320 | // or 321 | $dateTime = $dateTime->endOfMillennium(); 322 | 323 | // or 324 | 325 | $dateTime = $dateTime->startOfMonth()->endOfWeek()->startOfDay(); 326 | ``` 327 | 328 | ### Formatting and outputting date and time 329 | 330 | ```php 331 | $dateTime->toIso8601DateTimeExtended(); 332 | // or 333 | $dateTime->toIso8601DateTimeBasic(); 334 | 335 | // or 336 | 337 | $dateTime->toIso8601DateExtended(); 338 | // or 339 | $dateTime->toIso8601DateBasic(); 340 | 341 | // or 342 | 343 | $dateTime->toIso8601TimeExtended(); 344 | // or 345 | $dateTime->toIso8601TimeBasic(); 346 | 347 | // or 348 | 349 | $dateTime->toUnixSeconds(); 350 | // or 351 | $dateTime->toUnixMillis(); 352 | 353 | // or 354 | 355 | $dateTime->toFormat('d.m.Y'); 356 | // or 357 | $dateTime->toFormat('l jS \of F Y h:i:s A'); 358 | 359 | // or 360 | 361 | $dateTime->toDateTime(); 362 | // or 363 | $dateTime->toDateTimeImmutable(); 364 | ``` 365 | 366 | ### Fetching decades, centuries and millennia from dates 367 | 368 | ```php 369 | $dateTime->getDecadeOrdinal(); 370 | // or 371 | $dateTime->getDecadeNominal(); 372 | // or 373 | $dateTime->getYearInDecade(); 374 | 375 | // or 376 | 377 | $dateTime->getCenturyOrdinal(); 378 | // or 379 | $dateTime->getCenturyNominal(); 380 | // or 381 | $dateTime->getYearInCentury(); 382 | 383 | // or 384 | 385 | $dateTime->getMillenniumOrdinal(); 386 | // or 387 | $dateTime->getMillenniumNominal(); 388 | // or 389 | $dateTime->getYearInMillennium(); 390 | ``` 391 | 392 | ### Checking for daylight saving time (DST) 393 | 394 | ```php 395 | $dateTime->isDst(); 396 | ``` 397 | 398 | ### Checking for leap years 399 | 400 | ```php 401 | $dateTime->isLeapYear(); 402 | ``` 403 | 404 | ### Checking for special dates 405 | 406 | ```php 407 | $dateTime->isToday(); 408 | // or 409 | $dateTime->isYesterday(); 410 | // or 411 | $dateTime->isTomorrow(); 412 | 413 | // or 414 | 415 | $dateTime->isAnniversary(); 416 | 417 | // or 418 | 419 | $dateTime->isThisWeek(); 420 | // or 421 | $dateTime->isLastWeek(); 422 | // or 423 | $dateTime->isNextWeek(); 424 | 425 | // or 426 | 427 | $dateTime->isThisMonth(); 428 | // or 429 | $dateTime->isLastMonth(); 430 | // or 431 | $dateTime->isNextMonth(); 432 | 433 | // or 434 | 435 | $dateTime->isThisYear(); 436 | // or 437 | $dateTime->isLastYear(); 438 | // or 439 | $dateTime->isNextYear(); 440 | 441 | // or 442 | 443 | $dateTime->isThisDecade(); 444 | // or 445 | $dateTime->isLastDecade(); 446 | // or 447 | $dateTime->isNextDecade(); 448 | 449 | // or 450 | 451 | $dateTime->isThisCentury(); 452 | // or 453 | $dateTime->isLastCentury(); 454 | // or 455 | $dateTime->isNextCentury(); 456 | 457 | // or 458 | 459 | $dateTime->isThisMillennium(); 460 | // or 461 | $dateTime->isLastMillennium(); 462 | // or 463 | $dateTime->isNextMillennium(); 464 | ``` 465 | 466 | ### Calculating differences between two instances of date and time 467 | 468 | ```php 469 | $dateTime->calculateMillisUntil($otherDateTime); 470 | // or 471 | $dateTime->calculateSecondsUntil($otherDateTime); 472 | // or 473 | $dateTime->calculateMinutesUntil($otherDateTime); 474 | 475 | // or 476 | 477 | \Delight\Temporal\Duration $duration = $dateTime->calculateDurationUntil($otherDateTime); 478 | ``` 479 | 480 | ### Reading and writing durations of date and time 481 | 482 | ```php 483 | $duration->getYears(); 484 | // or 485 | $duration->getMonths(); 486 | // or 487 | $duration->getWeeks(); 488 | // or 489 | $duration->getDays(); 490 | 491 | // or 492 | 493 | $duration->getHours(); 494 | // or 495 | $duration->getMinutes(); 496 | // or 497 | $duration->getSeconds(); 498 | 499 | // or 500 | 501 | $duration->isPositive(); 502 | // or 503 | $duration->isNegative(); 504 | // or 505 | $duration->getSign(); 506 | 507 | // or 508 | 509 | $duration->toIso8601(); 510 | 511 | // or 512 | 513 | $duration->toAverageYears(); 514 | // or 515 | $duration->toAverageMonths(); 516 | // or 517 | $duration->toAverageWeeks(); 518 | // or 519 | $duration->toAverageDays(); 520 | // or 521 | $duration->toAverageHours(); 522 | // or 523 | $duration->toAverageMinutes(); 524 | // or 525 | $duration->toAverageSeconds(); 526 | 527 | // or 528 | 529 | $duration = \Delight\Temporal\Duration::fromDateTime(2, 7, 15, 20, 45, 0); 530 | // or 531 | $duration = \Delight\Temporal\Duration::fromDateTime(4, 0, 7); 532 | // or 533 | $duration = \Delight\Temporal\Duration::fromDateTime(3, 5, 26, 0, 0, 0, -1); 534 | 535 | // or 536 | 537 | $duration = \Delight\Temporal\Duration::fromWeeks(42); 538 | // or 539 | $duration = \Delight\Temporal\Duration::fromWeeks(8, -1); 540 | 541 | // or 542 | 543 | $duration = \Delight\Temporal\Duration::fromIso8601('P1M'); 544 | // or 545 | $duration = \Delight\Temporal\Duration::fromIso8601('P1Y14D'); 546 | // or 547 | $duration = \Delight\Temporal\Duration::fromIso8601('P1MT12H'); 548 | // or 549 | $duration = \Delight\Temporal\Duration::fromIso8601('P3Y6M4DT12H30M5S'); 550 | 551 | // or 552 | 553 | $duration = $duration->plus($otherDuration); 554 | // or 555 | $duration = $duration->multipliedBy(4); 556 | // or 557 | $duration = $duration->invert(); 558 | 559 | // or 560 | 561 | $duration = $duration->plus($otherDuration->invert())->multipliedBy(2); 562 | ``` 563 | 564 | ### Comparing instances of date and time with each other 565 | 566 | #### Equality 567 | 568 | ```php 569 | $dateTime->isSame($otherDateTime); 570 | // or 571 | $dateTime->isMinuteSame($otherDateTime); 572 | // or 573 | $dateTime->isHourSame($otherDateTime); 574 | // or 575 | $dateTime->isDaySame($otherDateTime); 576 | // or 577 | $dateTime->isMonthSame($otherDateTime); 578 | // or 579 | $dateTime->isYearSame($otherDateTime); 580 | // or 581 | $dateTime->isDecadeSame($otherDateTime); 582 | // or 583 | $dateTime->isCenturySame($otherDateTime); 584 | // or 585 | $dateTime->isMillenniumSame($otherDateTime); 586 | ``` 587 | 588 | #### Less than 589 | 590 | ```php 591 | $dateTime->isBefore($otherDateTime); 592 | // or 593 | $dateTime->isMinuteBefore($otherDateTime); 594 | // or 595 | $dateTime->isHourBefore($otherDateTime); 596 | // or 597 | $dateTime->isDayBefore($otherDateTime); 598 | // or 599 | $dateTime->isMonthBefore($otherDateTime); 600 | // or 601 | $dateTime->isYearBefore($otherDateTime); 602 | // or 603 | $dateTime->isDecadeBefore($otherDateTime); 604 | // or 605 | $dateTime->isCenturyBefore($otherDateTime); 606 | // or 607 | $dateTime->isMillenniumBefore($otherDateTime); 608 | ``` 609 | 610 | #### Greater than 611 | 612 | ```php 613 | $dateTime->isAfter($otherDateTime); 614 | // or 615 | $dateTime->isMinuteAfter($otherDateTime); 616 | // or 617 | $dateTime->isHourAfter($otherDateTime); 618 | // or 619 | $dateTime->isDayAfter($otherDateTime); 620 | // or 621 | $dateTime->isMonthAfter($otherDateTime); 622 | // or 623 | $dateTime->isYearAfter($otherDateTime); 624 | // or 625 | $dateTime->isDecadeAfter($otherDateTime); 626 | // or 627 | $dateTime->isCenturyAfter($otherDateTime); 628 | // or 629 | $dateTime->isMillenniumAfter($otherDateTime); 630 | ``` 631 | 632 | #### Less than or equal to 633 | 634 | ```php 635 | $dateTime->isBeforeOrSame($otherDateTime); 636 | // or 637 | $dateTime->isMinuteBeforeOrSame($otherDateTime); 638 | // or 639 | $dateTime->isHourBeforeOrSame($otherDateTime); 640 | // or 641 | $dateTime->isDayBeforeOrSame($otherDateTime); 642 | // or 643 | $dateTime->isMonthBeforeOrSame($otherDateTime); 644 | // or 645 | $dateTime->isYearBeforeOrSame($otherDateTime); 646 | // or 647 | $dateTime->isDecadeBeforeOrSame($otherDateTime); 648 | // or 649 | $dateTime->isCenturyBeforeOrSame($otherDateTime); 650 | // or 651 | $dateTime->isMillenniumBeforeOrSame($otherDateTime); 652 | ``` 653 | 654 | #### Greater than or equal to 655 | 656 | ```php 657 | $dateTime->isAfterOrSame($otherDateTime); 658 | // or 659 | $dateTime->isMinuteAfterOrSame($otherDateTime); 660 | // or 661 | $dateTime->isHourAfterOrSame($otherDateTime); 662 | // or 663 | $dateTime->isDayAfterOrSame($otherDateTime); 664 | // or 665 | $dateTime->isMonthAfterOrSame($otherDateTime); 666 | // or 667 | $dateTime->isYearAfterOrSame($otherDateTime); 668 | // or 669 | $dateTime->isDecadeAfterOrSame($otherDateTime); 670 | // or 671 | $dateTime->isCenturyAfterOrSame($otherDateTime); 672 | // or 673 | $dateTime->isMillenniumAfterOrSame($otherDateTime); 674 | ``` 675 | 676 | ### Checking whether dates and times are in the past or future 677 | 678 | ```php 679 | $dateTime->isPast(); 680 | // or 681 | $dateTime->isPastMinute(); 682 | // or 683 | $dateTime->isPastHour(); 684 | // or 685 | $dateTime->isPastDay(); 686 | // or 687 | $dateTime->isPastMonth(); 688 | // or 689 | $dateTime->isPastYear(); 690 | // or 691 | $dateTime->isPastDecade(); 692 | // or 693 | $dateTime->isPastCentury(); 694 | // or 695 | $dateTime->isPastMillennium(); 696 | 697 | // or 698 | 699 | $dateTime->isFuture(); 700 | // or 701 | $dateTime->isFutureMinute(); 702 | // or 703 | $dateTime->isFutureHour(); 704 | // or 705 | $dateTime->isFutureDay(); 706 | // or 707 | $dateTime->isFutureMonth(); 708 | // or 709 | $dateTime->isFutureYear(); 710 | // or 711 | $dateTime->isFutureDecade(); 712 | // or 713 | $dateTime->isFutureCentury(); 714 | // or 715 | $dateTime->isFutureMillennium(); 716 | ``` 717 | 718 | ### Changing and converting timezones 719 | 720 | ```php 721 | $dateTime = $dateTime->withTimeZone('UTC'); 722 | // or 723 | $dateTime = $dateTime->withTimeZone('America/Los_Angeles'); 724 | // or 725 | $dateTime = $dateTime->withTimeZone('Asia/Tokyo'); 726 | 727 | // or 728 | 729 | $dateTime = $dateTime->withDefaultTimeZone(); 730 | ``` 731 | 732 | ## Contributing 733 | 734 | All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed. 735 | 736 | ## License 737 | 738 | This project is licensed under the terms of the [MIT License](https://opensource.org/licenses/MIT). 739 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "delight-im/temporal", 3 | "description": "Immutable date and time for PHP with a convenient interface", 4 | "require": { 5 | "php": ">=5.6.0" 6 | }, 7 | "type": "library", 8 | "keywords": [ "date", "time", "datetime", "date-time", "manipulation", "parse", "format", "manipulate", "parsing", "formatting", "immutable" ], 9 | "homepage": "https://github.com/delight-im/PHP-Temporal", 10 | "license": "MIT", 11 | "autoload": { 12 | "psr-4": { 13 | "Delight\\Temporal\\": "src/" 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "e5b3c29fc738627e2cd17beec21d4a8e", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "stable", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": { 16 | "php": ">=5.6.0" 17 | }, 18 | "platform-dev": [] 19 | } 20 | -------------------------------------------------------------------------------- /src/Duration.php: -------------------------------------------------------------------------------- 1 | [ 23 | 'years' => Iso8601Duration::SUFFIX_YEARS, 24 | 'months' => Iso8601Duration::SUFFIX_MONTHS, 25 | 'weeks' => Iso8601Duration::SUFFIX_WEEKS, 26 | 'days' => Iso8601Duration::SUFFIX_DAYS 27 | ], 28 | self::PROPERTIES_KEY_TIME => [ 29 | 'hours' => Iso8601Duration::SUFFIX_HOURS, 30 | 'minutes' => Iso8601Duration::SUFFIX_MINUTES, 31 | 'seconds' => Iso8601Duration::SUFFIX_SECONDS 32 | ] 33 | ]; 34 | /** @internal */ 35 | const PROPERTIES_KEY_DATE = 0; 36 | /** @internal */ 37 | const PROPERTIES_KEY_TIME = 1; 38 | 39 | /** @var int the number of years */ 40 | private $years = 0; 41 | /** @var int the number of months */ 42 | private $months = 0; 43 | /** @var int the number of weeks */ 44 | private $weeks = 0; 45 | /** @var int the number of days */ 46 | private $days = 0; 47 | /** @var int the number of hours */ 48 | private $hours = 0; 49 | /** @var int the number of minutes */ 50 | private $minutes = 0; 51 | /** @var int the number of seconds */ 52 | private $seconds = 0; 53 | /** @var int the sign (either `-1` or `1`) for all components of this duration */ 54 | private $sign = 1; 55 | 56 | /** 57 | * Returns the number of years 58 | * 59 | * @return int 60 | */ 61 | public function getYears() { 62 | return $this->years; 63 | } 64 | 65 | /** 66 | * Returns the number of months 67 | * 68 | * @return int 69 | */ 70 | public function getMonths() { 71 | return $this->months; 72 | } 73 | 74 | /** 75 | * Returns the number of weeks 76 | * 77 | * @return int 78 | */ 79 | public function getWeeks() { 80 | return $this->weeks; 81 | } 82 | 83 | /** 84 | * Returns the number of days 85 | * 86 | * @return int 87 | */ 88 | public function getDays() { 89 | return $this->days; 90 | } 91 | 92 | /** 93 | * Returns the number of hours 94 | * 95 | * @return int 96 | */ 97 | public function getHours() { 98 | return $this->hours; 99 | } 100 | 101 | /** 102 | * Returns the number of minutes 103 | * 104 | * @return int 105 | */ 106 | public function getMinutes() { 107 | return $this->minutes; 108 | } 109 | 110 | /** 111 | * Returns the number of seconds 112 | * 113 | * @return int 114 | */ 115 | public function getSeconds() { 116 | return $this->seconds; 117 | } 118 | 119 | /** 120 | * Returns whether the duration is positive 121 | * 122 | * @return bool 123 | */ 124 | public function isPositive() { 125 | return $this->sign === 1; 126 | } 127 | 128 | /** 129 | * Returns whether the duration is negative 130 | * 131 | * @return bool 132 | */ 133 | public function isNegative() { 134 | return !$this->isPositive(); 135 | } 136 | 137 | /** 138 | * Returns the sign for all components of this duration 139 | * 140 | * @return int either `-1` or `1` 141 | */ 142 | public function getSign() { 143 | return $this->sign; 144 | } 145 | 146 | /** 147 | * Returns the duration as per ISO 8601 148 | * 149 | * @return string 150 | */ 151 | public function toIso8601() { 152 | if ($this->isEmpty()) { 153 | return Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . 0 . Iso8601Duration::SUFFIX_SECONDS; 154 | } 155 | 156 | $str = $this->sign == -1 ? '-' : ''; 157 | 158 | $str .= Iso8601Duration::PREFIX; 159 | 160 | foreach (self::PROPERTIES as $group => $properties) { 161 | if ($group === self::PROPERTIES_KEY_TIME) { 162 | if ($this->hasTime()) { 163 | $str .= Iso8601Duration::PREFIX_TIME; 164 | } 165 | } 166 | 167 | foreach ($properties as $property => $suffix) { 168 | if (!empty($this->$property)) { 169 | $str .= $this->$property; 170 | $str .= $suffix; 171 | } 172 | } 173 | } 174 | 175 | return $str; 176 | } 177 | 178 | /** 179 | * Returns the duration as a number of (average) years 180 | * 181 | * @return float 182 | */ 183 | public function toAverageYears() { 184 | return $this->toAverageSeconds() / 31556952; 185 | } 186 | 187 | /** 188 | * Returns the duration as a number of (average) months 189 | * 190 | * @return float 191 | */ 192 | public function toAverageMonths() { 193 | return $this->toAverageSeconds() / 2629746; 194 | } 195 | 196 | /** 197 | * Returns the duration as a number of (average) weeks 198 | * 199 | * @return float 200 | */ 201 | public function toAverageWeeks() { 202 | return $this->toAverageSeconds() / 604800; 203 | } 204 | 205 | /** 206 | * Returns the duration as a number of (average) days 207 | * 208 | * @return float 209 | */ 210 | public function toAverageDays() { 211 | return $this->toAverageSeconds() / 86400; 212 | } 213 | 214 | /** 215 | * Returns the duration as a number of (average) hours 216 | * 217 | * @return float 218 | */ 219 | public function toAverageHours() { 220 | return $this->toAverageSeconds() / 3600; 221 | } 222 | 223 | /** 224 | * Returns the duration as a number of (average) minutes 225 | * 226 | * @return float 227 | */ 228 | public function toAverageMinutes() { 229 | return $this->toAverageSeconds() / 60; 230 | } 231 | 232 | /** 233 | * Returns the duration as a number of (average) seconds 234 | * 235 | * @return float 236 | */ 237 | public function toAverageSeconds() { 238 | $seconds = 0; 239 | 240 | $seconds += $this->years * 31556952; 241 | $seconds += $this->months * 2629746; 242 | $seconds += $this->weeks * 604800; 243 | $seconds += $this->days * 86400; 244 | $seconds += $this->hours * 3600; 245 | $seconds += $this->minutes * 60; 246 | $seconds += $this->seconds; 247 | $seconds *= $this->sign; 248 | 249 | return $seconds; 250 | } 251 | 252 | /** 253 | * Adds another duration to this duration 254 | * 255 | * @param self $other the duration to add 256 | * @return self a new instance 257 | * @throws Error (do *not* catch) 258 | */ 259 | public function plus(self $other) { 260 | if (($this->hasWeeks() && $other->hasDateTime()) || ($this->hasDateTime() && $other->hasWeeks())) { 261 | throw new IllegalDurationOperationError(); 262 | } 263 | 264 | $copy = $this->copy(); 265 | 266 | foreach (self::PROPERTIES as $properties) { 267 | foreach (\array_keys($properties) as $property) { 268 | $copy->$property += $other->$property; 269 | } 270 | } 271 | 272 | return $copy; 273 | } 274 | 275 | /** 276 | * Multiplies the duration by the specified factor 277 | * 278 | * @param int $factor the positive factor to multiply by 279 | * @return self a new instance 280 | * @throws Error (do *not* catch) 281 | */ 282 | public function multipliedBy($factor) { 283 | $factor = (int) $factor; 284 | 285 | if ($factor < 0) { 286 | throw new IllegalDurationOperationError; 287 | } 288 | 289 | $copy = $this->copy(); 290 | 291 | foreach (self::PROPERTIES as $properties) { 292 | foreach (\array_keys($properties) as $property) { 293 | $copy->$property *= $factor; 294 | } 295 | } 296 | 297 | return $copy; 298 | } 299 | 300 | /** 301 | * Inverts the sign of the duration 302 | * 303 | * @return self a new instance 304 | */ 305 | public function invert() { 306 | $copy = $this->copy(); 307 | 308 | $copy->sign *= -1; 309 | 310 | return $copy; 311 | } 312 | 313 | /** 314 | * Returns whether the duration specifies a number of weeks 315 | * 316 | * @return bool 317 | */ 318 | public function hasWeeks() { 319 | return $this->weeks !== 0; 320 | } 321 | 322 | /** 323 | * Returns whether the duration specifies date and/or time 324 | * 325 | * @return bool 326 | */ 327 | public function hasDateTime() { 328 | return $this->hasDate() || $this->hasTime(); 329 | } 330 | 331 | /** 332 | * Returns whether the duration specifies a date 333 | * 334 | * @return bool 335 | */ 336 | public function hasDate() { 337 | return $this->years !== 0 || $this->months !== 0 || $this->days !== 0; 338 | } 339 | 340 | /** 341 | * Returns whether the duration specifies time 342 | * 343 | * @return bool 344 | */ 345 | public function hasTime() { 346 | return $this->hours !== 0 || $this->minutes !== 0 || $this->seconds !== 0; 347 | } 348 | 349 | /** 350 | * Returns whether the duration is empty 351 | * 352 | * @return bool 353 | */ 354 | public function isEmpty() { 355 | return !$this->hasDateTime() && !$this->hasWeeks(); 356 | } 357 | 358 | /** 359 | * Creates a copy of this instance 360 | * 361 | * @return self a new instance 362 | */ 363 | public function copy() { 364 | return clone $this; 365 | } 366 | 367 | public function __toString() { 368 | return $this->toIso8601(); 369 | } 370 | 371 | /** 372 | * Creates a new instance from date and/or time 373 | * 374 | * @param int|null $years (optional) a positive number of years 375 | * @param int|null $months (optional) a positive number of months 376 | * @param int|null $days (optional) a positive number of days 377 | * @param int|null $hours (optional) a positive number of hours 378 | * @param int|null $minutes (optional) a positive number of minutes 379 | * @param int|null $seconds (optional) a positive number of seconds 380 | * @param int|null $sign (optional) the sign (either `-1` or `1`) for all components of this duration 381 | * @return self the new instance 382 | */ 383 | public static function fromDateTime($years = null, $months = null, $days = null, $hours = null, $minutes = null, $seconds = null, $sign = null) { 384 | $instance = new self(); 385 | 386 | $instance->setProperty('years', $years); 387 | $instance->setProperty('months', $months); 388 | $instance->setProperty('days', $days); 389 | $instance->setProperty('hours', $hours); 390 | $instance->setProperty('minutes', $minutes); 391 | $instance->setProperty('seconds', $seconds); 392 | $instance->setProperty('sign', $sign == -1 ? -1 : 1, true); 393 | 394 | return $instance; 395 | } 396 | 397 | /** 398 | * Creates a new instance from a number of weeks 399 | * 400 | * @param int $weeks a positive number of weeks 401 | * @param int|null $sign (optional) the sign (either `-1` or `1`) of this duration 402 | * @return self the new instance 403 | */ 404 | public static function fromWeeks($weeks, $sign = null) { 405 | $instance = new self(); 406 | 407 | $instance->setProperty('weeks', $weeks); 408 | $instance->setProperty('sign', $sign == -1 ? -1 : 1, true); 409 | 410 | return $instance; 411 | } 412 | 413 | /** 414 | * Creates a new instance from a duration as per ISO 8601 415 | * 416 | * @param string $duration the duration as per ISO 8601 417 | * @return self the new instance 418 | * @throws Error (do *not* catch) 419 | */ 420 | public static function fromIso8601($duration) { 421 | if (\preg_match('/^' . Iso8601Duration::REGEX . '$/', $duration, $matches)) { 422 | $sign = !empty($matches[1]) && $matches[1] === '-' ? -1 : 1; 423 | $weeks = !empty($matches[2]) ? (int) $matches[2] : 0; 424 | $dateTime = [ 425 | !empty($matches[3]) ? (int) $matches[3] : 0, 426 | !empty($matches[4]) ? (int) $matches[4] : 0, 427 | !empty($matches[5]) ? (int) $matches[5] : 0, 428 | !empty($matches[6]) ? (int) $matches[6] : 0, 429 | !empty($matches[7]) ? (int) $matches[7] : 0, 430 | !empty($matches[8]) ? (int) $matches[8] : 0, 431 | ]; 432 | 433 | if ($weeks !== 0) { 434 | if (!empty(\array_filter($dateTime))) { 435 | throw new InvalidDurationFormatError(); 436 | } 437 | 438 | return self::fromWeeks($weeks, $sign); 439 | } 440 | else { 441 | return self::fromDateTime( 442 | $dateTime[0], 443 | $dateTime[1], 444 | $dateTime[2], 445 | $dateTime[3], 446 | $dateTime[4], 447 | $dateTime[5], 448 | $sign 449 | ); 450 | } 451 | } 452 | else { 453 | throw new InvalidDurationFormatError(); 454 | } 455 | } 456 | 457 | /** 458 | * Sets the specified property to the given value 459 | * 460 | * @param string $name the name of the property 461 | * @param int $value the value to set 462 | * @param bool|null $allowNegative (optional) whether to allow negative values 463 | * @throws Error (do *not* catch) 464 | */ 465 | private function setProperty($name, $value, $allowNegative = null) { 466 | if (empty($value)) { 467 | return; 468 | } 469 | 470 | $name = (string) $name; 471 | $value = (int) $value; 472 | 473 | if ($allowNegative !== true && $value < 0) { 474 | throw new InvalidDurationComponentError(); 475 | } 476 | 477 | $this->$name = $value; 478 | } 479 | 480 | /** Do not allow direct instantiation */ 481 | private function __construct() {} 482 | 483 | } 484 | -------------------------------------------------------------------------------- /src/Iso8601/Iso8601Date.php: -------------------------------------------------------------------------------- 1 | plusIso8601Duration( 36 | Iso8601Duration::PREFIX . (int) $years . Iso8601Duration::SUFFIX_YEARS 37 | ); 38 | } 39 | 40 | /** 41 | * Returns an instance with the specified number of months added 42 | * 43 | * @param int $months the number of months to add 44 | * @return self a new instance 45 | */ 46 | public function plusMonths($months) { 47 | return $this->plusIso8601Duration( 48 | Iso8601Duration::PREFIX . (int) $months . Iso8601Duration::SUFFIX_MONTHS 49 | ); 50 | } 51 | 52 | /** 53 | * Returns an instance with the specified number of weeks added 54 | * 55 | * @param int $weeks the number of weeks to add 56 | * @return self a new instance 57 | */ 58 | public function plusWeeks($weeks) { 59 | return $this->plusIso8601Duration( 60 | Iso8601Duration::PREFIX . (int) $weeks . Iso8601Duration::SUFFIX_WEEKS 61 | ); 62 | } 63 | 64 | /** 65 | * Returns an instance with the specified number of days added 66 | * 67 | * @param int $days the number of days to add 68 | * @return self a new instance 69 | */ 70 | public function plusDays($days) { 71 | return $this->plusIso8601Duration( 72 | Iso8601Duration::PREFIX . (int) $days . Iso8601Duration::SUFFIX_DAYS 73 | ); 74 | } 75 | 76 | /** 77 | * Returns an instance with the specified number of hours added 78 | * 79 | * @param int $hours the number of hours to add 80 | * @return self a new instance 81 | */ 82 | public function plusHours($hours) { 83 | return $this->plusIso8601Duration( 84 | Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . (int) $hours . Iso8601Duration::SUFFIX_HOURS 85 | ); 86 | } 87 | 88 | /** 89 | * Returns an instance with the specified number of minutes added 90 | * 91 | * @param int $minutes the number of minutes to add 92 | * @return self a new instance 93 | */ 94 | public function plusMinutes($minutes) { 95 | return $this->plusIso8601Duration( 96 | Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . (int) $minutes . Iso8601Duration::SUFFIX_MINUTES 97 | ); 98 | } 99 | 100 | /** 101 | * Returns an instance with the specified number of seconds added 102 | * 103 | * @param int $seconds the number of seconds to add 104 | * @return self a new instance 105 | */ 106 | public function plusSeconds($seconds) { 107 | return $this->plusIso8601Duration( 108 | Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . (int) $seconds . Iso8601Duration::SUFFIX_SECONDS 109 | ); 110 | } 111 | 112 | /** 113 | * Returns an instance with the specified duration added 114 | * 115 | * Alias of {@see plusIso8601Duration} 116 | * 117 | * @param string $duration the duration as per ISO 8601 to add 118 | * @return self a new instance 119 | */ 120 | public function plusDuration($duration) { 121 | return $this->plusIso8601Duration($duration); 122 | } 123 | 124 | /** 125 | * Returns an instance with the specified duration as per ISO 8601 added 126 | * 127 | * @param string $iso8601Duration the duration as per ISO 8601 to add 128 | * @return self a new instance 129 | */ 130 | public function plusIso8601Duration($iso8601Duration) { 131 | return $this->withIso8601DurationApplied($iso8601Duration, 'add'); 132 | } 133 | 134 | /** 135 | * Returns an instance with the specified number of years subtracted 136 | * 137 | * @param int $years the number of years to subtract 138 | * @return self a new instance 139 | */ 140 | public function minusYears($years) { 141 | return $this->minusIso8601Duration( 142 | Iso8601Duration::PREFIX . (int) $years . Iso8601Duration::SUFFIX_YEARS 143 | ); 144 | } 145 | 146 | /** 147 | * Returns an instance with the specified number of months subtracted 148 | * 149 | * @param int $months the number of months to subtract 150 | * @return self a new instance 151 | */ 152 | public function minusMonths($months) { 153 | return $this->minusIso8601Duration( 154 | Iso8601Duration::PREFIX . (int) $months . Iso8601Duration::SUFFIX_MONTHS 155 | ); 156 | } 157 | 158 | /** 159 | * Returns an instance with the specified number of weeks subtracted 160 | * 161 | * @param int $weeks the number of weeks to subtract 162 | * @return self a new instance 163 | */ 164 | public function minusWeeks($weeks) { 165 | return $this->minusIso8601Duration( 166 | Iso8601Duration::PREFIX . (int) $weeks . Iso8601Duration::SUFFIX_WEEKS 167 | ); 168 | } 169 | 170 | /** 171 | * Returns an instance with the specified number of days subtracted 172 | * 173 | * @param int $days the number of days to subtract 174 | * @return self a new instance 175 | */ 176 | public function minusDays($days) { 177 | return $this->minusIso8601Duration( 178 | Iso8601Duration::PREFIX . (int) $days . Iso8601Duration::SUFFIX_DAYS 179 | ); 180 | } 181 | 182 | /** 183 | * Returns an instance with the specified number of hours subtracted 184 | * 185 | * @param int $hours the number of hours to subtract 186 | * @return self a new instance 187 | */ 188 | public function minusHours($hours) { 189 | return $this->minusIso8601Duration( 190 | Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . (int) $hours . Iso8601Duration::SUFFIX_HOURS 191 | ); 192 | } 193 | 194 | /** 195 | * Returns an instance with the specified number of minutes subtracted 196 | * 197 | * @param int $minutes the number of minutes to subtract 198 | * @return self a new instance 199 | */ 200 | public function minusMinutes($minutes) { 201 | return $this->minusIso8601Duration( 202 | Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . (int) $minutes . Iso8601Duration::SUFFIX_MINUTES 203 | ); 204 | } 205 | 206 | /** 207 | * Returns an instance with the specified number of seconds subtracted 208 | * 209 | * @param int $seconds the number of seconds to subtract 210 | * @return self a new instance 211 | */ 212 | public function minusSeconds($seconds) { 213 | return $this->minusIso8601Duration( 214 | Iso8601Duration::PREFIX . Iso8601Duration::PREFIX_TIME . (int) $seconds . Iso8601Duration::SUFFIX_SECONDS 215 | ); 216 | } 217 | 218 | /** 219 | * Returns an instance with the specified duration subtracted 220 | * 221 | * Alias of {@see minusIso8601Duration} 222 | * 223 | * @param string $duration the duration as per ISO 8601 to subtract 224 | * @return self a new instance 225 | */ 226 | public function minusDuration($duration) { 227 | return $this->minusIso8601Duration($duration); 228 | } 229 | 230 | /** 231 | * Returns an instance with the specified duration as per ISO 8601 subtracted 232 | * 233 | * @param string $iso8601Duration the duration as per ISO 8601 to subtract 234 | * @return self a new instance 235 | */ 236 | public function minusIso8601Duration($iso8601Duration) { 237 | return $this->withIso8601DurationApplied($iso8601Duration, 'sub'); 238 | } 239 | 240 | /** 241 | * Returns the year 242 | * 243 | * @return int 244 | */ 245 | public function getYear() { 246 | return (int) $this->dateTime->format('Y'); 247 | } 248 | 249 | /** 250 | * Returns the month of the year 251 | * 252 | * @return int the month of the year (`1` through `12`) 253 | */ 254 | public function getMonth() { 255 | return (int) $this->dateTime->format('n'); 256 | } 257 | 258 | /** 259 | * Returns the day of the month 260 | * 261 | * @return int the day of the month (`1` through `31`) 262 | */ 263 | public function getDay() { 264 | return (int) $this->dateTime->format('j'); 265 | } 266 | 267 | /** 268 | * Returns the hour of the day 269 | * 270 | * @return int the hour of the day (`0` through `23`) 271 | */ 272 | public function getHour() { 273 | return (int) $this->dateTime->format('G'); 274 | } 275 | 276 | /** 277 | * Returns the minute of the hour 278 | * 279 | * @return int the minute of the hour (`0` through `59`) 280 | */ 281 | public function getMinute() { 282 | return (int) $this->dateTime->format('i'); 283 | } 284 | 285 | /** 286 | * Returns the second of the minute 287 | * 288 | * @return int the second of the minute (`0` through `59`) 289 | */ 290 | public function getSecond() { 291 | return (int) $this->dateTime->format('s'); 292 | } 293 | 294 | /** 295 | * Returns the day of the week 296 | * 297 | * @return int the day of the week (`1` for Monday through `7` for Sunday) 298 | */ 299 | public function getWeekday() { 300 | return (int) $this->dateTime->format('N'); 301 | } 302 | 303 | /** 304 | * Returns whether the date is a Monday 305 | * 306 | * @return bool 307 | */ 308 | public function isMonday() { 309 | return $this->getWeekday() === Iso8601Weekday::MONDAY; 310 | } 311 | 312 | /** 313 | * Returns whether the date is a Tuesday 314 | * 315 | * @return bool 316 | */ 317 | public function isTuesday() { 318 | return $this->getWeekday() === Iso8601Weekday::TUESDAY; 319 | } 320 | 321 | /** 322 | * Returns whether the date is a Wednesday 323 | * 324 | * @return bool 325 | */ 326 | public function isWednesday() { 327 | return $this->getWeekday() === Iso8601Weekday::WEDNESDAY; 328 | } 329 | 330 | /** 331 | * Returns whether the date is a Thursday 332 | * 333 | * @return bool 334 | */ 335 | public function isThursday() { 336 | return $this->getWeekday() === Iso8601Weekday::THURSDAY; 337 | } 338 | 339 | /** 340 | * Returns whether the date is a Friday 341 | * 342 | * @return bool 343 | */ 344 | public function isFriday() { 345 | return $this->getWeekday() === Iso8601Weekday::FRIDAY; 346 | } 347 | 348 | /** 349 | * Returns whether the date is a Saturday 350 | * 351 | * @return bool 352 | */ 353 | public function isSaturday() { 354 | return $this->getWeekday() === Iso8601Weekday::SATURDAY; 355 | } 356 | 357 | /** 358 | * Returns whether the date is a Sunday 359 | * 360 | * @return bool 361 | */ 362 | public function isSunday() { 363 | return $this->getWeekday() === Iso8601Weekday::SUNDAY; 364 | } 365 | 366 | /** 367 | * Returns the number of the week in the year 368 | * 369 | * @return int the number of the week in the year (`1` through `53`) 370 | */ 371 | public function getWeekOfYear() { 372 | return (int) $this->dateTime->format('W'); 373 | } 374 | 375 | /** 376 | * Returns the year that belongs to the number of the week 377 | * 378 | * This number may differ from the actual year number in early January and late December 379 | * 380 | * @return int 381 | */ 382 | public function getWeekYear() { 383 | return (int) $this->dateTime->format('o'); 384 | } 385 | 386 | /** 387 | * Returns the day of the year 388 | * 389 | * @return int the day of the year (`1` through `366`) 390 | */ 391 | public function getDayOfYear() { 392 | return (int) $this->dateTime->format('z') + 1; 393 | } 394 | 395 | /** 396 | * Returns an instance with the year set as specified 397 | * 398 | * @param int $year the year to set 399 | * @return self a new instance 400 | */ 401 | public function withYear($year) { 402 | return $this->withDate($year, null, null); 403 | } 404 | 405 | /** 406 | * Returns an instance with the month of the year set as specified 407 | * 408 | * @param int $month the month of the year (`1` through `12`) to set 409 | * @return self a new instance 410 | */ 411 | public function withMonth($month) { 412 | return $this->withDate(null, $month, null); 413 | } 414 | 415 | /** 416 | * Returns an instance with the day of the month set as specified 417 | * 418 | * @param int $day the day of the month (`1` through `31`) to set 419 | * @return self a new instance 420 | */ 421 | public function withDay($day) { 422 | return $this->withDate(null, null, $day); 423 | } 424 | 425 | /** 426 | * Returns an instance with the date set as specified 427 | * 428 | * @param int|null $year (optional) the year to set 429 | * @param int|null $month (optional) the month of the year (`1` through `12`) to set 430 | * @param int|null $day (optional) the day of the month (`1` through `31`) to set 431 | * @return self a new instance 432 | */ 433 | public function withDate($year = null, $month = null, $day = null) { 434 | $copy = $this->copy(); 435 | 436 | $copy->dateTime->setDate( 437 | $year !== null ? (int) $year : $copy->getYear(), 438 | $month !== null ? (int) $month : $copy->getMonth(), 439 | $day !== null ? (int) $day : $copy->getDay() 440 | ); 441 | 442 | return $copy; 443 | } 444 | 445 | /** 446 | * Returns an instance with the hour of the day set as specified 447 | * 448 | * @param int $hour the hour of the day (`0` through `23`) to set 449 | * @return self a new instance 450 | */ 451 | public function withHour($hour) { 452 | return $this->withTime($hour, null, null); 453 | } 454 | 455 | /** 456 | * Returns an instance with the minute of the hour set as specified 457 | * 458 | * @param int $minute the minute of the hour (`0` through `59`) to set 459 | * @return self a new instance 460 | */ 461 | public function withMinute($minute) { 462 | return $this->withTime(null, $minute, null); 463 | } 464 | 465 | /** 466 | * Returns an instance with the second of the minute set as specified 467 | * 468 | * @param int $second the second of the minute (`0` through `59`) to set 469 | * @return self a new instance 470 | */ 471 | public function withSecond($second) { 472 | return $this->withTime(null, null, $second); 473 | } 474 | 475 | /** 476 | * Returns an instance with the time set as specified 477 | * 478 | * @param int|null $hour (optional) the hour of the day (`0` through `23`) to set 479 | * @param int|null $minute (optional) the minute of the hour (`0` through `59`) to set 480 | * @param int|null $second (optional) the second of the minute (`0` through `59`) to set 481 | * @return self a new instance 482 | */ 483 | public function withTime($hour = null, $minute = null, $second = null) { 484 | $copy = $this->copy(); 485 | 486 | $copy->dateTime->setTime( 487 | $hour !== null ? (int) $hour : $copy->getHour(), 488 | $minute !== null ? (int) $minute : $copy->getMinute(), 489 | $second !== null ? (int) $second : $copy->getSecond() 490 | ); 491 | 492 | return $copy; 493 | } 494 | 495 | /** 496 | * Returns an instance with the time set to the start of its minute 497 | * 498 | * @return self a new instance 499 | */ 500 | public function startOfMinute() { 501 | return $this->withSecond(0); 502 | } 503 | 504 | /** 505 | * Returns an instance with the time set to the end of its minute 506 | * 507 | * @return self a new instance 508 | */ 509 | public function endOfMinute() { 510 | return $this->withSecond(59); 511 | } 512 | 513 | /** 514 | * Returns an instance with the time set to the start of its hour 515 | * 516 | * @return self a new instance 517 | */ 518 | public function startOfHour() { 519 | return $this->withTime(null, 0, 0); 520 | } 521 | 522 | /** 523 | * Returns an instance with the time set to the end of its hour 524 | * 525 | * @return self a new instance 526 | */ 527 | public function endOfHour() { 528 | return $this->withTime(null, 59, 59); 529 | } 530 | 531 | /** 532 | * Returns an instance with the time set to the start of its day 533 | * 534 | * @return self a new instance 535 | */ 536 | public function startOfDay() { 537 | return $this->withTime(0, 0, 0); 538 | } 539 | 540 | /** 541 | * Returns an instance with the time set to the end of its day 542 | * 543 | * @return self a new instance 544 | */ 545 | public function endOfDay() { 546 | return $this->withTime(23, 59, 59); 547 | } 548 | 549 | /** 550 | * Returns an instance with the time set to the start of its week 551 | * 552 | * @return self a new instance 553 | */ 554 | public function startOfWeek() { 555 | return $this->withModification('monday this week midnight'); 556 | } 557 | 558 | /** 559 | * Returns an instance with the time set to the end of its week 560 | * 561 | * @return self a new instance 562 | */ 563 | public function endOfWeek() { 564 | return $this->withModification('sunday this week T235959'); 565 | } 566 | 567 | /** 568 | * Returns an instance with the time set to the start of its month 569 | * 570 | * @return self a new instance 571 | */ 572 | public function startOfMonth() { 573 | return $this->withModification('first day of this month midnight'); 574 | } 575 | 576 | /** 577 | * Returns an instance with the time set to the end of its month 578 | * 579 | * @return self a new instance 580 | */ 581 | public function endOfMonth() { 582 | return $this->withModification('last day of this month T235959'); 583 | } 584 | 585 | /** 586 | * Returns an instance with the time set to the start of its year 587 | * 588 | * @return self a new instance 589 | */ 590 | public function startOfYear() { 591 | return $this->withModification('1 january midnight'); 592 | } 593 | 594 | /** 595 | * Returns an instance with the time set to the end of its year 596 | * 597 | * @return self a new instance 598 | */ 599 | public function endOfYear() { 600 | return $this->withModification('31 december T235959'); 601 | } 602 | 603 | /** 604 | * Returns an instance with the time set to the start of its decade 605 | * 606 | * @return self a new instance 607 | */ 608 | public function startOfDecade() { 609 | return $this->withModification( 610 | '1 january midnight -' . ($this->getYearInDecade()) . ' years' 611 | ); 612 | } 613 | 614 | /** 615 | * Returns an instance with the time set to the end of its decade 616 | * 617 | * @return self a new instance 618 | */ 619 | public function endOfDecade() { 620 | $monthDayTime = '31 december T235959'; 621 | $year = (9 - ($this->getYearInDecade())) . ' years'; 622 | 623 | return $this->withModification($monthDayTime . ' ' . $year); 624 | } 625 | 626 | /** 627 | * Returns an instance with the time set to the start of its century 628 | * 629 | * @return self a new instance 630 | */ 631 | public function startOfCentury() { 632 | return $this->withModification( 633 | '1 january midnight -' . ($this->getYearInCentury()) . ' years' 634 | ); 635 | } 636 | 637 | /** 638 | * Returns an instance with the time set to the end of its century 639 | * 640 | * @return self a new instance 641 | */ 642 | public function endOfCentury() { 643 | $monthDayTime = '31 december T235959'; 644 | $year = (99 - ($this->getYearInCentury())) . ' years'; 645 | 646 | return $this->withModification($monthDayTime . ' ' . $year); 647 | } 648 | 649 | /** 650 | * Returns an instance with the time set to the start of its millennium 651 | * 652 | * @return self a new instance 653 | */ 654 | public function startOfMillennium() { 655 | return $this->withModification( 656 | '1 january midnight -' . ($this->getYearInMillennium()) . ' years' 657 | ); 658 | } 659 | 660 | /** 661 | * Returns an instance with the time set to the end of its millennium 662 | * 663 | * @return self a new instance 664 | */ 665 | public function endOfMillennium() { 666 | $monthDayTime = '31 december T235959'; 667 | $year = (999 - ($this->getYearInMillennium())) . ' years'; 668 | 669 | return $this->withModification($monthDayTime . ' ' . $year); 670 | } 671 | 672 | /** 673 | * Returns the date and time as per ISO 8601 674 | * 675 | * This uses the extended format of ISO 8601 which includes separators for better human readability 676 | * 677 | * Alias of {@see toIso8601DateTimeExtended} 678 | * 679 | * @return string the date and time as per ISO 8601 (e.g. `1969-07-20T20:18:04+00:00`) 680 | */ 681 | public function toIso8601DateTime() { 682 | return $this->toIso8601DateTimeExtended(); 683 | } 684 | 685 | /** 686 | * Returns the date and time as per ISO 8601 687 | * 688 | * This uses the extended format of ISO 8601 which includes separators for better human readability 689 | * 690 | * @return string the date and time as per ISO 8601 (e.g. `1969-07-20T20:18:04+00:00`) 691 | */ 692 | public function toIso8601DateTimeExtended() { 693 | return $this->dateTime->format(Iso8601DateTime::FORMAT_EXTENDED); 694 | } 695 | 696 | /** 697 | * Returns the date and time as per ISO 8601 698 | * 699 | * This uses the basic format of ISO 8601 which omits separators for more efficient machine processing 700 | * 701 | * @return string the date and time as per ISO 8601 (e.g. `19690720T201804+0000`) 702 | */ 703 | public function toIso8601DateTimeBasic() { 704 | return $this->dateTime->format(Iso8601DateTime::FORMAT_BASIC); 705 | } 706 | 707 | /** 708 | * Returns the date as per ISO 8601 709 | * 710 | * This uses the extended format of ISO 8601 which includes separators for better human readability 711 | * 712 | * Alias of {@see toIso8601DateExtended} 713 | * 714 | * @return string the date as per ISO 8601 (e.g. `1969-07-20`) 715 | */ 716 | public function toIso8601Date() { 717 | return $this->toIso8601DateExtended(); 718 | } 719 | 720 | /** 721 | * Returns the date as per ISO 8601 722 | * 723 | * This uses the extended format of ISO 8601 which includes separators for better human readability 724 | * 725 | * @return string the date as per ISO 8601 (e.g. `1969-07-20`) 726 | */ 727 | public function toIso8601DateExtended() { 728 | return $this->dateTime->format(Iso8601Date::FORMAT_EXTENDED); 729 | } 730 | 731 | /** 732 | * Returns the date as per ISO 8601 733 | * 734 | * This uses the basic format of ISO 8601 which omits separators for more efficient machine processing 735 | * 736 | * @return string the date as per ISO 8601 (e.g. `19690720`) 737 | */ 738 | public function toIso8601DateBasic() { 739 | return $this->dateTime->format(Iso8601Date::FORMAT_BASIC); 740 | } 741 | 742 | /** 743 | * Returns the time as per ISO 8601 744 | * 745 | * This uses the extended format of ISO 8601 which includes separators for better human readability 746 | * 747 | * Alias of {@see toIso8601TimeExtended} 748 | * 749 | * @return string the time as per ISO 8601 (e.g. `20:18:04+00:00`) 750 | */ 751 | public function toIso8601Time() { 752 | return $this->toIso8601TimeExtended(); 753 | } 754 | 755 | /** 756 | * Returns the time as per ISO 8601 757 | * 758 | * This uses the extended format of ISO 8601 which includes separators for better human readability 759 | * 760 | * @return string the time as per ISO 8601 (e.g. `20:18:04+00:00`) 761 | */ 762 | public function toIso8601TimeExtended() { 763 | return $this->dateTime->format(Iso8601Time::FORMAT_EXTENDED); 764 | } 765 | 766 | /** 767 | * Returns the time as per ISO 8601 768 | * 769 | * This uses the basic format of ISO 8601 which omits separators for more efficient machine processing 770 | * 771 | * @return string the time as per ISO 8601 (e.g. `201804+0000`) 772 | */ 773 | public function toIso8601TimeBasic() { 774 | return $this->dateTime->format(Iso8601Time::FORMAT_BASIC); 775 | } 776 | 777 | /** 778 | * Returns the UNIX timestamp in seconds 779 | * 780 | * @return int 781 | */ 782 | public function toUnixSeconds() { 783 | return (int) $this->dateTime->format(Unix::FORMAT_INTEGER); 784 | } 785 | 786 | /** 787 | * Returns the UNIX timestamp in milliseconds 788 | * 789 | * @return int 790 | */ 791 | public function toUnixMillis() { 792 | $secondsWithFraction = (float) $this->dateTime->format(Unix::FORMAT_FLOAT); 793 | 794 | return (int) \round($secondsWithFraction * 1000); 795 | } 796 | 797 | /** 798 | * Returns the date and/or time as requested in the specified format 799 | * 800 | * @param string $format the desired format, described using the formatting options of {@see \date} 801 | * @return string 802 | */ 803 | public function toFormat($format) { 804 | return $this->dateTime->format($format); 805 | } 806 | 807 | /** 808 | * Returns the date and time as a {@see \DateTime} instance 809 | * 810 | * @return \DateTime 811 | */ 812 | public function toDateTime() { 813 | return clone $this->dateTime; 814 | } 815 | 816 | /** 817 | * Returns the date and time as a {@see \DateTimeImmutable} instance 818 | * 819 | * @return \DateTimeImmutable 820 | */ 821 | public function toDateTimeImmutable() { 822 | return \DateTimeImmutable::createFromMutable($this->dateTime); 823 | } 824 | 825 | /** 826 | * Returns the ordinal number for the decade 827 | * 828 | * @return int the ordinal number for the decade (e.g. `197` for year `1969`) 829 | */ 830 | public function getDecadeOrdinal() { 831 | return $this->getDecadeSignificand() + self::signum($this->getYear()); 832 | } 833 | 834 | /** 835 | * Returns the nominal number for the decade 836 | * 837 | * @return int the nominal number for the decade (e.g. `1960` for year `1969`) 838 | */ 839 | public function getDecadeNominal() { 840 | return $this->getDecadeSignificand() * 10; 841 | } 842 | 843 | /** 844 | * Returns the ordinal number for the century 845 | * 846 | * @return int the ordinal number for the century (e.g. `20` for year `1969`) 847 | */ 848 | public function getCenturyOrdinal() { 849 | return $this->getCenturySignificand() + self::signum($this->getYear()); 850 | } 851 | 852 | /** 853 | * Returns the nominal number for the century 854 | * 855 | * @return int the nominal number for the century (e.g. `1900` for year `1969`) 856 | */ 857 | public function getCenturyNominal() { 858 | return $this->getCenturySignificand() * 100; 859 | } 860 | 861 | /** 862 | * Returns the ordinal number for the millennium 863 | * 864 | * @return int the ordinal number for the millennium (e.g. `2` for year `1969`) 865 | */ 866 | public function getMillenniumOrdinal() { 867 | return $this->getMillenniumSignificand() + self::signum($this->getYear()); 868 | } 869 | 870 | /** 871 | * Returns the nominal number for the millennium 872 | * 873 | * @return int the nominal number for the millennium (e.g. `1000` for year `1969`) 874 | */ 875 | public function getMillenniumNominal() { 876 | return $this->getMillenniumSignificand() * 1000; 877 | } 878 | 879 | /** 880 | * Returns whether daylight saving time (DST) is in effect 881 | * 882 | * Alias of {@see isDaylightSavingTime} 883 | * 884 | * @return bool 885 | */ 886 | public function isDst() { 887 | return $this->isDaylightSavingTime(); 888 | } 889 | 890 | /** 891 | * Returns whether daylight saving time (DST) is in effect 892 | * 893 | * @return bool 894 | */ 895 | public function isDaylightSavingTime() { 896 | return $this->dateTime->format('I') == 1; 897 | } 898 | 899 | /** 900 | * Returns whether the year is a leap year 901 | * 902 | * @return bool 903 | */ 904 | public function isLeapYear() { 905 | return $this->dateTime->format('L') == 1; 906 | } 907 | 908 | /** 909 | * Returns the number of the year in its decade 910 | * 911 | * @return int the number of the year in its decade (`0` through `9`) 912 | */ 913 | public function getYearInDecade() { 914 | return $this->getYear() % 10; 915 | } 916 | 917 | /** 918 | * Returns the number of the year in its century 919 | * 920 | * @return int the number of the year in its century (`0` through `99`) 921 | */ 922 | public function getYearInCentury() { 923 | return $this->getYear() % 100; 924 | } 925 | 926 | /** 927 | * Returns the number of the year in its millennium 928 | * 929 | * @return int the number of the year in its millennium (`0` through `999`) 930 | */ 931 | public function getYearInMillennium() { 932 | return $this->getYear() % 1000; 933 | } 934 | 935 | /** 936 | * Returns whether the current instance is today 937 | * 938 | * @return bool 939 | */ 940 | public function isToday() { 941 | return $this->isDaySame(self::now()); 942 | } 943 | 944 | /** 945 | * Returns whether the current instance is yesterday 946 | * 947 | * @return bool 948 | */ 949 | public function isYesterday() { 950 | return $this->isDaySame(self::yesterday()); 951 | } 952 | 953 | /** 954 | * Returns whether the current instance is tomorrow 955 | * 956 | * @return bool 957 | */ 958 | public function isTomorrow() { 959 | return $this->isDaySame(self::tomorrow()); 960 | } 961 | 962 | /** 963 | * Returns whether the current instance has the same month and day as today 964 | * 965 | * @return bool 966 | */ 967 | public function isAnniversary() { 968 | $now = self::now(); 969 | 970 | return $this->getMonth() === $now->getMonth() && $this->getDay() === $now->getDay(); 971 | } 972 | 973 | /** 974 | * Returns the duration in milliseconds from this instance to the other instance 975 | * 976 | * @param self $other 977 | * @return float 978 | */ 979 | public function calculateMillisUntil(self $other) { 980 | return $this->calculateSecondsUntil($other) * 1000; 981 | } 982 | 983 | /** 984 | * Returns the duration in seconds from this instance to the other instance 985 | * 986 | * @param self $other 987 | * @return float 988 | */ 989 | public function calculateSecondsUntil(self $other) { 990 | return (float) $other->dateTime->format(Unix::FORMAT_FLOAT) - (float) $this->dateTime->format(Unix::FORMAT_FLOAT); 991 | } 992 | 993 | /** 994 | * Returns the duration in minutes from this instance to the other instance 995 | * 996 | * @param self $other 997 | * @return float 998 | */ 999 | public function calculateMinutesUntil(self $other) { 1000 | return $this->calculateSecondsUntil($other) / 60; 1001 | } 1002 | 1003 | /** 1004 | * Returns the duration from this instance to the other instance 1005 | * 1006 | * Alias of {@see calculateIso8601DurationUntil} 1007 | * 1008 | * @param self $other 1009 | * @return Duration 1010 | */ 1011 | public function calculateDurationUntil(self $other) { 1012 | return $this->calculateIso8601DurationUntil($other); 1013 | } 1014 | 1015 | /** 1016 | * Returns the duration from this instance to the other instance 1017 | * 1018 | * @param self $other 1019 | * @return Duration 1020 | */ 1021 | public function calculateIso8601DurationUntil(self $other) { 1022 | $components = $this->dateTime->diff($other->dateTime); 1023 | 1024 | return Duration::fromDateTime( 1025 | $components->y, 1026 | $components->m, 1027 | $components->d, 1028 | $components->h, 1029 | $components->i, 1030 | $components->s, 1031 | $components->invert == 1 ? -1 : 1 1032 | ); 1033 | } 1034 | 1035 | /** 1036 | * Returns whether the other instance has the same date and time 1037 | * 1038 | * @param self $other the other instance to compare with 1039 | * @return bool 1040 | */ 1041 | public function isSame(self $other) { 1042 | return self::compareInstances($this, $other, 15) === 0; 1043 | } 1044 | 1045 | /** 1046 | * Returns whether the other instance has the same date, hour and minute 1047 | * 1048 | * @param self $other the other instance to compare with 1049 | * @return bool 1050 | */ 1051 | public function isMinuteSame(self $other) { 1052 | return self::compareInstances($this, $other, 13) === 0; 1053 | } 1054 | 1055 | /** 1056 | * Returns whether the other instance has the same date and hour 1057 | * 1058 | * @param self $other the other instance to compare with 1059 | * @return bool 1060 | */ 1061 | public function isHourSame(self $other) { 1062 | return self::compareInstances($this, $other, 11) === 0; 1063 | } 1064 | 1065 | /** 1066 | * Returns whether the other instance has the same date 1067 | * 1068 | * @param self $other the other instance to compare with 1069 | * @return bool 1070 | */ 1071 | public function isDaySame(self $other) { 1072 | return self::compareInstances($this, $other, 8) === 0; 1073 | } 1074 | 1075 | /** 1076 | * Returns whether the other instance has the same year and month 1077 | * 1078 | * @param self $other the other instance to compare with 1079 | * @return bool 1080 | */ 1081 | public function isMonthSame(self $other) { 1082 | return self::compareInstances($this, $other, 6) === 0; 1083 | } 1084 | 1085 | /** 1086 | * Returns whether the other instance has the same year 1087 | * 1088 | * @param self $other the other instance to compare with 1089 | * @return bool 1090 | */ 1091 | public function isYearSame(self $other) { 1092 | return self::compareInstances($this, $other, 4) === 0; 1093 | } 1094 | 1095 | /** 1096 | * Returns whether the other instance has the same decade 1097 | * 1098 | * @param self $other the other instance to compare with 1099 | * @return bool 1100 | */ 1101 | public function isDecadeSame(self $other) { 1102 | return self::compareInstances($this, $other, 3) === 0; 1103 | } 1104 | 1105 | /** 1106 | * Returns whether the other instance has the same century 1107 | * 1108 | * @param self $other the other instance to compare with 1109 | * @return bool 1110 | */ 1111 | public function isCenturySame(self $other) { 1112 | return self::compareInstances($this, $other, 2) === 0; 1113 | } 1114 | 1115 | /** 1116 | * Returns whether the other instance has the same millennium 1117 | * 1118 | * @param self $other the other instance to compare with 1119 | * @return bool 1120 | */ 1121 | public function isMillenniumSame(self $other) { 1122 | return self::compareInstances($this, $other, 1) === 0; 1123 | } 1124 | 1125 | /** 1126 | * Returns whether the current instance is before the other one with respect to date and time 1127 | * 1128 | * @param self $other the other instance to compare with 1129 | * @return bool 1130 | */ 1131 | public function isBefore(self $other) { 1132 | return self::compareInstances($this, $other, 15) < 0; 1133 | } 1134 | 1135 | /** 1136 | * Returns whether the current instance is before the other one with respect to date, hour and minute 1137 | * 1138 | * @param self $other the other instance to compare with 1139 | * @return bool 1140 | */ 1141 | public function isMinuteBefore(self $other) { 1142 | return self::compareInstances($this, $other, 13) < 0; 1143 | } 1144 | 1145 | /** 1146 | * Returns whether the current instance is before the other one with respect to date and hour 1147 | * 1148 | * @param self $other the other instance to compare with 1149 | * @return bool 1150 | */ 1151 | public function isHourBefore(self $other) { 1152 | return self::compareInstances($this, $other, 11) < 0; 1153 | } 1154 | 1155 | /** 1156 | * Returns whether the current instance is before the other one with respect to the date 1157 | * 1158 | * @param self $other the other instance to compare with 1159 | * @return bool 1160 | */ 1161 | public function isDayBefore(self $other) { 1162 | return self::compareInstances($this, $other, 8) < 0; 1163 | } 1164 | 1165 | /** 1166 | * Returns whether the current instance is before the other one with respect to year and month 1167 | * 1168 | * @param self $other the other instance to compare with 1169 | * @return bool 1170 | */ 1171 | public function isMonthBefore(self $other) { 1172 | return self::compareInstances($this, $other, 6) < 0; 1173 | } 1174 | 1175 | /** 1176 | * Returns whether the current instance is before the other one with respect to the year 1177 | * 1178 | * @param self $other the other instance to compare with 1179 | * @return bool 1180 | */ 1181 | public function isYearBefore(self $other) { 1182 | return self::compareInstances($this, $other, 4) < 0; 1183 | } 1184 | 1185 | /** 1186 | * Returns whether the current instance is before the other one with respect to the decade 1187 | * 1188 | * @param self $other the other instance to compare with 1189 | * @return bool 1190 | */ 1191 | public function isDecadeBefore(self $other) { 1192 | return self::compareInstances($this, $other, 3) < 0; 1193 | } 1194 | 1195 | /** 1196 | * Returns whether the current instance is before the other one with respect to the century 1197 | * 1198 | * @param self $other the other instance to compare with 1199 | * @return bool 1200 | */ 1201 | public function isCenturyBefore(self $other) { 1202 | return self::compareInstances($this, $other, 2) < 0; 1203 | } 1204 | 1205 | /** 1206 | * Returns whether the current instance is before the other one with respect to the millennium 1207 | * 1208 | * @param self $other the other instance to compare with 1209 | * @return bool 1210 | */ 1211 | public function isMillenniumBefore(self $other) { 1212 | return self::compareInstances($this, $other, 1) < 0; 1213 | } 1214 | 1215 | /** 1216 | * Returns whether the current instance is after the other one with respect to date and time 1217 | * 1218 | * @param self $other the other instance to compare with 1219 | * @return bool 1220 | */ 1221 | public function isAfter(self $other) { 1222 | return self::compareInstances($this, $other, 15) > 0; 1223 | } 1224 | 1225 | /** 1226 | * Returns whether the current instance is after the other one with respect to date, hour and minute 1227 | * 1228 | * @param self $other the other instance to compare with 1229 | * @return bool 1230 | */ 1231 | public function isMinuteAfter(self $other) { 1232 | return self::compareInstances($this, $other, 13) > 0; 1233 | } 1234 | 1235 | /** 1236 | * Returns whether the current instance is after the other one with respect to date and hour 1237 | * 1238 | * @param self $other the other instance to compare with 1239 | * @return bool 1240 | */ 1241 | public function isHourAfter(self $other) { 1242 | return self::compareInstances($this, $other, 11) > 0; 1243 | } 1244 | 1245 | /** 1246 | * Returns whether the current instance is after the other one with respect to the date 1247 | * 1248 | * @param self $other the other instance to compare with 1249 | * @return bool 1250 | */ 1251 | public function isDayAfter(self $other) { 1252 | return self::compareInstances($this, $other, 8) > 0; 1253 | } 1254 | 1255 | /** 1256 | * Returns whether the current instance is after the other one with respect to year and month 1257 | * 1258 | * @param self $other the other instance to compare with 1259 | * @return bool 1260 | */ 1261 | public function isMonthAfter(self $other) { 1262 | return self::compareInstances($this, $other, 6) > 0; 1263 | } 1264 | 1265 | /** 1266 | * Returns whether the current instance is after the other one with respect to the year 1267 | * 1268 | * @param self $other the other instance to compare with 1269 | * @return bool 1270 | */ 1271 | public function isYearAfter(self $other) { 1272 | return self::compareInstances($this, $other, 4) > 0; 1273 | } 1274 | 1275 | /** 1276 | * Returns whether the current instance is after the other one with respect to the decade 1277 | * 1278 | * @param self $other the other instance to compare with 1279 | * @return bool 1280 | */ 1281 | public function isDecadeAfter(self $other) { 1282 | return self::compareInstances($this, $other, 3) > 0; 1283 | } 1284 | 1285 | /** 1286 | * Returns whether the current instance is after the other one with respect to the century 1287 | * 1288 | * @param self $other the other instance to compare with 1289 | * @return bool 1290 | */ 1291 | public function isCenturyAfter(self $other) { 1292 | return self::compareInstances($this, $other, 2) > 0; 1293 | } 1294 | 1295 | /** 1296 | * Returns whether the current instance is after the other one with respect to the millennium 1297 | * 1298 | * @param self $other the other instance to compare with 1299 | * @return bool 1300 | */ 1301 | public function isMillenniumAfter(self $other) { 1302 | return self::compareInstances($this, $other, 1) > 0; 1303 | } 1304 | 1305 | /** 1306 | * Returns whether the current instance is before or equal to the other one with respect to date and time 1307 | * 1308 | * @param self $other the other instance to compare with 1309 | * @return bool 1310 | */ 1311 | public function isBeforeOrSame(self $other) { 1312 | return !$this->isAfter($other); 1313 | } 1314 | 1315 | /** 1316 | * Returns whether the current instance is before or equal to the other one with respect to date, hour and minute 1317 | * 1318 | * @param self $other the other instance to compare with 1319 | * @return bool 1320 | */ 1321 | public function isMinuteBeforeOrSame(self $other) { 1322 | return !$this->isMinuteAfter($other); 1323 | } 1324 | 1325 | /** 1326 | * Returns whether the current instance is before or equal to the other one with respect to date and hour 1327 | * 1328 | * @param self $other the other instance to compare with 1329 | * @return bool 1330 | */ 1331 | public function isHourBeforeOrSame(self $other) { 1332 | return !$this->isHourAfter($other); 1333 | } 1334 | 1335 | /** 1336 | * Returns whether the current instance is before or equal to the other one with respect to the date 1337 | * 1338 | * @param self $other the other instance to compare with 1339 | * @return bool 1340 | */ 1341 | public function isDayBeforeOrSame(self $other) { 1342 | return !$this->isDayAfter($other); 1343 | } 1344 | 1345 | /** 1346 | * Returns whether the current instance is before or equal to the other one with respect to year and month 1347 | * 1348 | * @param self $other the other instance to compare with 1349 | * @return bool 1350 | */ 1351 | public function isMonthBeforeOrSame(self $other) { 1352 | return !$this->isMonthAfter($other); 1353 | } 1354 | 1355 | /** 1356 | * Returns whether the current instance is before or equal to the other one with respect to the year 1357 | * 1358 | * @param self $other the other instance to compare with 1359 | * @return bool 1360 | */ 1361 | public function isYearBeforeOrSame(self $other) { 1362 | return !$this->isYearAfter($other); 1363 | } 1364 | 1365 | /** 1366 | * Returns whether the current instance is before or equal to the other one with respect to the decade 1367 | * 1368 | * @param self $other the other instance to compare with 1369 | * @return bool 1370 | */ 1371 | public function isDecadeBeforeOrSame(self $other) { 1372 | return !$this->isDecadeAfter($other); 1373 | } 1374 | 1375 | /** 1376 | * Returns whether the current instance is before or equal to the other one with respect to the century 1377 | * 1378 | * @param self $other the other instance to compare with 1379 | * @return bool 1380 | */ 1381 | public function isCenturyBeforeOrSame(self $other) { 1382 | return !$this->isCenturyAfter($other); 1383 | } 1384 | 1385 | /** 1386 | * Returns whether the current instance is before or equal to the other one with respect to the millennium 1387 | * 1388 | * @param self $other the other instance to compare with 1389 | * @return bool 1390 | */ 1391 | public function isMillenniumBeforeOrSame(self $other) { 1392 | return !$this->isMillenniumAfter($other); 1393 | } 1394 | 1395 | /** 1396 | * Returns whether the current instance is after or equal to the other one with respect to date and time 1397 | * 1398 | * @param self $other the other instance to compare with 1399 | * @return bool 1400 | */ 1401 | public function isAfterOrSame(self $other) { 1402 | return !$this->isBefore($other); 1403 | } 1404 | 1405 | /** 1406 | * Returns whether the current instance is after or equal to the other one with respect to date, hour and minute 1407 | * 1408 | * @param self $other the other instance to compare with 1409 | * @return bool 1410 | */ 1411 | public function isMinuteAfterOrSame(self $other) { 1412 | return !$this->isMinuteBefore($other); 1413 | } 1414 | 1415 | /** 1416 | * Returns whether the current instance is after or equal to the other one with respect to date and hour 1417 | * 1418 | * @param self $other the other instance to compare with 1419 | * @return bool 1420 | */ 1421 | public function isHourAfterOrSame(self $other) { 1422 | return !$this->isHourBefore($other); 1423 | } 1424 | 1425 | /** 1426 | * Returns whether the current instance is after or equal to the other one with respect to the date 1427 | * 1428 | * @param self $other the other instance to compare with 1429 | * @return bool 1430 | */ 1431 | public function isDayAfterOrSame(self $other) { 1432 | return !$this->isDayBefore($other); 1433 | } 1434 | 1435 | /** 1436 | * Returns whether the current instance is after or equal to the other one with respect to year and month 1437 | * 1438 | * @param self $other the other instance to compare with 1439 | * @return bool 1440 | */ 1441 | public function isMonthAfterOrSame(self $other) { 1442 | return !$this->isMonthBefore($other); 1443 | } 1444 | 1445 | /** 1446 | * Returns whether the current instance is after or equal to the other one with respect to the year 1447 | * 1448 | * @param self $other the other instance to compare with 1449 | * @return bool 1450 | */ 1451 | public function isYearAfterOrSame(self $other) { 1452 | return !$this->isYearBefore($other); 1453 | } 1454 | 1455 | /** 1456 | * Returns whether the current instance is after or equal to the other one with respect to the decade 1457 | * 1458 | * @param self $other the other instance to compare with 1459 | * @return bool 1460 | */ 1461 | public function isDecadeAfterOrSame(self $other) { 1462 | return !$this->isDecadeBefore($other); 1463 | } 1464 | 1465 | /** 1466 | * Returns whether the current instance is after or equal to the other one with respect to the century 1467 | * 1468 | * @param self $other the other instance to compare with 1469 | * @return bool 1470 | */ 1471 | public function isCenturyAfterOrSame(self $other) { 1472 | return !$this->isCenturyBefore($other); 1473 | } 1474 | 1475 | /** 1476 | * Returns whether the current instance is after or equal to the other one with respect to the millennium 1477 | * 1478 | * @param self $other the other instance to compare with 1479 | * @return bool 1480 | */ 1481 | public function isMillenniumAfterOrSame(self $other) { 1482 | return !$this->isMillenniumBefore($other); 1483 | } 1484 | 1485 | /** 1486 | * Returns whether the current instance is in the past with respect to date and time 1487 | * 1488 | * @return bool 1489 | */ 1490 | public function isPast() { 1491 | return $this->isBefore(self::now()); 1492 | } 1493 | 1494 | /** 1495 | * Returns whether the current instance is in the past with respect to date, hour and minute 1496 | * 1497 | * @return bool 1498 | */ 1499 | public function isPastMinute() { 1500 | return $this->isMinuteBefore(self::now()); 1501 | } 1502 | 1503 | /** 1504 | * Returns whether the current instance is in the past with respect to date and hour 1505 | * 1506 | * @return bool 1507 | */ 1508 | public function isPastHour() { 1509 | return $this->isHourBefore(self::now()); 1510 | } 1511 | 1512 | /** 1513 | * Returns whether the current instance is in the past with respect to the date 1514 | * 1515 | * @return bool 1516 | */ 1517 | public function isPastDay() { 1518 | return $this->isDayBefore(self::now()); 1519 | } 1520 | 1521 | /** 1522 | * Returns whether the current instance is in the past with respect to year and month 1523 | * 1524 | * @return bool 1525 | */ 1526 | public function isPastMonth() { 1527 | return $this->isMonthBefore(self::now()); 1528 | } 1529 | 1530 | /** 1531 | * Returns whether the current instance is in the past with respect to the year 1532 | * 1533 | * @return bool 1534 | */ 1535 | public function isPastYear() { 1536 | return $this->isYearBefore(self::now()); 1537 | } 1538 | 1539 | /** 1540 | * Returns whether the current instance is in the past with respect to the decade 1541 | * 1542 | * @return bool 1543 | */ 1544 | public function isPastDecade() { 1545 | return $this->isDecadeBefore(self::now()); 1546 | } 1547 | 1548 | /** 1549 | * Returns whether the current instance is in the past with respect to the century 1550 | * 1551 | * @return bool 1552 | */ 1553 | public function isPastCentury() { 1554 | return $this->isCenturyBefore(self::now()); 1555 | } 1556 | 1557 | /** 1558 | * Returns whether the current instance is in the past with respect to the millennium 1559 | * 1560 | * @return bool 1561 | */ 1562 | public function isPastMillennium() { 1563 | return $this->isMillenniumBefore(self::now()); 1564 | } 1565 | 1566 | /** 1567 | * Returns whether the current instance is in the future with respect to date and time 1568 | * 1569 | * @return bool 1570 | */ 1571 | public function isFuture() { 1572 | return $this->isAfter(self::now()); 1573 | } 1574 | 1575 | /** 1576 | * Returns whether the current instance is in the future with respect to date, hour and minute 1577 | * 1578 | * @return bool 1579 | */ 1580 | public function isFutureMinute() { 1581 | return $this->isMinuteAfter(self::now()); 1582 | } 1583 | 1584 | /** 1585 | * Returns whether the current instance is in the future with respect to date and hour 1586 | * 1587 | * @return bool 1588 | */ 1589 | public function isFutureHour() { 1590 | return $this->isHourAfter(self::now()); 1591 | } 1592 | 1593 | /** 1594 | * Returns whether the current instance is in the future with respect to the date 1595 | * 1596 | * @return bool 1597 | */ 1598 | public function isFutureDay() { 1599 | return $this->isDayAfter(self::now()); 1600 | } 1601 | 1602 | /** 1603 | * Returns whether the current instance is in the future with respect to year and month 1604 | * 1605 | * @return bool 1606 | */ 1607 | public function isFutureMonth() { 1608 | return $this->isMonthAfter(self::now()); 1609 | } 1610 | 1611 | /** 1612 | * Returns whether the current instance is in the future with respect to the year 1613 | * 1614 | * @return bool 1615 | */ 1616 | public function isFutureYear() { 1617 | return $this->isYearAfter(self::now()); 1618 | } 1619 | 1620 | /** 1621 | * Returns whether the current instance is in the future with respect to the decade 1622 | * 1623 | * @return bool 1624 | */ 1625 | public function isFutureDecade() { 1626 | return $this->isDecadeAfter(self::now()); 1627 | } 1628 | 1629 | /** 1630 | * Returns whether the current instance is in the future with respect to the century 1631 | * 1632 | * @return bool 1633 | */ 1634 | public function isFutureCentury() { 1635 | return $this->isCenturyAfter(self::now()); 1636 | } 1637 | 1638 | /** 1639 | * Returns whether the current instance is in the future with respect to the millennium 1640 | * 1641 | * @return bool 1642 | */ 1643 | public function isFutureMillennium() { 1644 | return $this->isMillenniumAfter(self::now()); 1645 | } 1646 | 1647 | /** 1648 | * Returns whether the current instance was last week 1649 | * 1650 | * @return bool 1651 | */ 1652 | public function isLastWeek() { 1653 | return $this->getWeekOfYear() === self::now()->minusWeeks(1)->getWeekOfYear(); 1654 | } 1655 | 1656 | /** 1657 | * Returns whether the current instance is this week 1658 | * 1659 | * @return bool 1660 | */ 1661 | public function isThisWeek() { 1662 | return $this->getWeekOfYear() === self::now()->getWeekOfYear(); 1663 | } 1664 | 1665 | /** 1666 | * Returns whether the current instance will be next week 1667 | * 1668 | * @return bool 1669 | */ 1670 | public function isNextWeek() { 1671 | return $this->getWeekOfYear() === self::now()->plusWeeks(1)->getWeekOfYear(); 1672 | } 1673 | 1674 | /** 1675 | * Returns whether the current instance was last month 1676 | * 1677 | * @return bool 1678 | */ 1679 | public function isLastMonth() { 1680 | return $this->getMonth() === self::now()->minusMonths(1)->getMonth(); 1681 | } 1682 | 1683 | /** 1684 | * Returns whether the current instance is this month 1685 | * 1686 | * @return bool 1687 | */ 1688 | public function isThisMonth() { 1689 | return $this->getMonth() === self::now()->getMonth(); 1690 | } 1691 | 1692 | /** 1693 | * Returns whether the current instance will be next month 1694 | * 1695 | * @return bool 1696 | */ 1697 | public function isNextMonth() { 1698 | return $this->getMonth() === self::now()->plusMonths(1)->getMonth(); 1699 | } 1700 | 1701 | /** 1702 | * Returns whether the current instance was last year 1703 | * 1704 | * @return bool 1705 | */ 1706 | public function isLastYear() { 1707 | return $this->getYear() === self::now()->minusYears(1)->getYear(); 1708 | } 1709 | 1710 | /** 1711 | * Returns whether the current instance is this year 1712 | * 1713 | * @return bool 1714 | */ 1715 | public function isThisYear() { 1716 | return $this->getYear() === self::now()->getYear(); 1717 | } 1718 | 1719 | /** 1720 | * Returns whether the current instance will be next year 1721 | * 1722 | * @return bool 1723 | */ 1724 | public function isNextYear() { 1725 | return $this->getYear() === self::now()->plusYears(1)->getYear(); 1726 | } 1727 | 1728 | /** 1729 | * Returns whether the current instance was last decade 1730 | * 1731 | * @return bool 1732 | */ 1733 | public function isLastDecade() { 1734 | return $this->getDecadeSignificand() === self::now()->minusYears(10)->getDecadeSignificand(); 1735 | } 1736 | 1737 | /** 1738 | * Returns whether the current instance is this decade 1739 | * 1740 | * @return bool 1741 | */ 1742 | public function isThisDecade() { 1743 | return $this->getDecadeSignificand() === self::now()->getDecadeSignificand(); 1744 | } 1745 | 1746 | /** 1747 | * Returns whether the current instance will be next decade 1748 | * 1749 | * @return bool 1750 | */ 1751 | public function isNextDecade() { 1752 | return $this->getDecadeSignificand() === self::now()->plusYears(10)->getDecadeSignificand(); 1753 | } 1754 | 1755 | /** 1756 | * Returns whether the current instance was last century 1757 | * 1758 | * @return bool 1759 | */ 1760 | public function isLastCentury() { 1761 | return $this->getCenturySignificand() === self::now()->minusYears(100)->getCenturySignificand(); 1762 | } 1763 | 1764 | /** 1765 | * Returns whether the current instance is this century 1766 | * 1767 | * @return bool 1768 | */ 1769 | public function isThisCentury() { 1770 | return $this->getCenturySignificand() === self::now()->getCenturySignificand(); 1771 | } 1772 | 1773 | /** 1774 | * Returns whether the current instance will be next century 1775 | * 1776 | * @return bool 1777 | */ 1778 | public function isNextCentury() { 1779 | return $this->getCenturySignificand() === self::now()->plusYears(100)->getCenturySignificand(); 1780 | } 1781 | 1782 | /** 1783 | * Returns whether the current instance was last millennium 1784 | * 1785 | * @return bool 1786 | */ 1787 | public function isLastMillennium() { 1788 | return $this->getMillenniumSignificand() === self::now()->minusYears(1000)->getMillenniumSignificand(); 1789 | } 1790 | 1791 | /** 1792 | * Returns whether the current instance is this millennium 1793 | * 1794 | * @return bool 1795 | */ 1796 | public function isThisMillennium() { 1797 | return $this->getMillenniumSignificand() === self::now()->getMillenniumSignificand(); 1798 | } 1799 | 1800 | /** 1801 | * Returns whether the current instance will be next millennium 1802 | * 1803 | * @return bool 1804 | */ 1805 | public function isNextMillennium() { 1806 | return $this->getMillenniumSignificand() === self::now()->plusYears(1000)->getMillenniumSignificand(); 1807 | } 1808 | 1809 | /** 1810 | * Returns an instance with the time zone changed to that with the specified identifier 1811 | * 1812 | * Passing `null` will set the default time zone 1813 | * 1814 | * @param string $identifier|null the identifier of the time zone to use (e.g. `Asia/Tokyo`) or `null` 1815 | * @return self a new instance 1816 | */ 1817 | public function withTimeZone($identifier = null) { 1818 | return $this->copy()->setTimeZone($identifier); 1819 | } 1820 | 1821 | /** 1822 | * Returns an instance with the time zone changed to the default one 1823 | * 1824 | * @return self a new instance 1825 | */ 1826 | public function withDefaultTimeZone() { 1827 | return $this->withTimeZone(null); 1828 | } 1829 | 1830 | /** 1831 | * Returns a copy of the current instance 1832 | * 1833 | * @return self a new instance 1834 | */ 1835 | public function copy() { 1836 | return clone $this; 1837 | } 1838 | 1839 | public function __clone() { 1840 | $this->dateTime = clone $this->dateTime; 1841 | } 1842 | 1843 | public function __toString() { 1844 | return $this->toIso8601DateTimeExtended(); 1845 | } 1846 | 1847 | /** 1848 | * Creates a new instance with the current date and time 1849 | * 1850 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1851 | * @return self the new instance 1852 | */ 1853 | public static function now($timeZone = null) { 1854 | if (self::hasMockNow()) { 1855 | return self::getMockNow()->withTimeZone($timeZone); 1856 | } 1857 | else { 1858 | return self::createInstance( 1859 | new \DateTime(null, self::makeTimeZone($timeZone)) 1860 | ); 1861 | } 1862 | } 1863 | 1864 | /** 1865 | * Returns a new instance with the date and time from the specified UNIX timestamp 1866 | * 1867 | * @param int|float $unixSeconds the UNIX timestamp in seconds 1868 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1869 | * @return self the new instance 1870 | */ 1871 | public static function fromUnixSeconds($unixSeconds, $timeZone = null) { 1872 | return self::createInstanceFromFormat( 1873 | Unix::FORMAT_FLOAT, 1874 | \number_format($unixSeconds, 6, '.', ''), 1875 | $timeZone 1876 | ); 1877 | } 1878 | 1879 | /** 1880 | * Returns a new instance with the date and time from the specified UNIX timestamp 1881 | * 1882 | * @param int $unixMillis the UNIX timestamp in milliseconds 1883 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1884 | * @return self the new instance 1885 | */ 1886 | public static function fromUnixMillis($unixMillis, $timeZone = null) { 1887 | return self::fromUnixSeconds($unixMillis / 1000, $timeZone); 1888 | } 1889 | 1890 | /** 1891 | * Creates a new instance with the specified date and time as per ISO 8601 1892 | * 1893 | * Alias of {@see fromIso8601DateTimeExtended} 1894 | * 1895 | * @param string $dateTime the date and time in extended format as per ISO 8601 1896 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1897 | * @return self the new instance 1898 | */ 1899 | public static function fromIso8601DateTime($dateTime, $timeZone = null) { 1900 | return self::fromIso8601DateTimeExtended($dateTime, $timeZone); 1901 | } 1902 | 1903 | /** 1904 | * Creates a new instance with the specified date and time as per ISO 8601 1905 | * 1906 | * @param string $dateTime the date and time in extended format as per ISO 8601 1907 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1908 | * @return self the new instance 1909 | */ 1910 | public static function fromIso8601DateTimeExtended($dateTime, $timeZone = null) { 1911 | return self::createInstanceFromFormat(Iso8601DateTime::FORMAT_EXTENDED, $dateTime, $timeZone); 1912 | } 1913 | 1914 | /** 1915 | * Creates a new instance with the specified date and time as per ISO 8601 1916 | * 1917 | * @param string $dateTime the date and time in basic format as per ISO 8601 1918 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1919 | * @return self the new instance 1920 | */ 1921 | public static function fromIso8601DateTimeBasic($dateTime, $timeZone = null) { 1922 | return self::createInstanceFromFormat(Iso8601DateTime::FORMAT_BASIC, $dateTime, $timeZone); 1923 | } 1924 | 1925 | /** 1926 | * Creates a new instance with the specified date as per ISO 8601 1927 | * 1928 | * Alias of {@see fromIso8601DateExtended} 1929 | * 1930 | * @param string $date the date in extended format as per ISO 8601 1931 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1932 | * @return self the new instance 1933 | */ 1934 | public static function fromIso8601Date($date, $timeZone = null) { 1935 | return self::fromIso8601DateExtended($date, $timeZone); 1936 | } 1937 | 1938 | /** 1939 | * Creates a new instance with the specified date as per ISO 8601 1940 | * 1941 | * @param string $date the date in extended format as per ISO 8601 1942 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1943 | * @return self the new instance 1944 | */ 1945 | public static function fromIso8601DateExtended($date, $timeZone = null) { 1946 | return self::createInstanceFromFormat( 1947 | Iso8601Date::FORMAT_EXTENDED, 1948 | $date, 1949 | $timeZone 1950 | ); 1951 | } 1952 | 1953 | /** 1954 | * Creates a new instance with the specified date as per ISO 8601 1955 | * 1956 | * @param string $date the date in basic format as per ISO 8601 1957 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1958 | * @return self the new instance 1959 | */ 1960 | public static function fromIso8601DateBasic($date, $timeZone = null) { 1961 | return self::createInstanceFromFormat( 1962 | Iso8601Date::FORMAT_BASIC, 1963 | $date, 1964 | $timeZone 1965 | ); 1966 | } 1967 | 1968 | /** 1969 | * Creates a new instance with the specified time as per ISO 8601 1970 | * 1971 | * Alias of {@see fromIso8601TimeExtended} 1972 | * 1973 | * @param string $time the time in extended format as per ISO 8601 1974 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1975 | * @return self the new instance 1976 | */ 1977 | public static function fromIso8601Time($time, $timeZone = null) { 1978 | return self::fromIso8601TimeExtended($time, $timeZone); 1979 | } 1980 | 1981 | /** 1982 | * Creates a new instance with the specified time as per ISO 8601 1983 | * 1984 | * @param string $time the time in extended format as per ISO 8601 1985 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1986 | * @return self the new instance 1987 | */ 1988 | public static function fromIso8601TimeExtended($time, $timeZone = null) { 1989 | return self::createInstanceFromFormat(Iso8601Time::FORMAT_EXTENDED, $time, $timeZone); 1990 | } 1991 | 1992 | /** 1993 | * Creates a new instance with the specified time as per ISO 8601 1994 | * 1995 | * @param string $time the time in basic format as per ISO 8601 1996 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 1997 | * @return self the new instance 1998 | */ 1999 | public static function fromIso8601TimeBasic($time, $timeZone = null) { 2000 | return self::createInstanceFromFormat(Iso8601Time::FORMAT_BASIC, $time, $timeZone); 2001 | } 2002 | 2003 | /** 2004 | * Creates a new instance with the specified date and time 2005 | * 2006 | * Any component that is not set will be set to "now" 2007 | * 2008 | * @param int|null $year (optional) the year to set 2009 | * @param int|null $month (optional) the month of the year (`1` through `12`) to set 2010 | * @param int|null $day (optional) the day of the month (`1` through `31`) to set 2011 | * @param int|null $hour (optional) the hour of the day (`0` through `23`) to set 2012 | * @param int|null $minute (optional) the minute of the hour (`0` through `59`) to set 2013 | * @param int|null $second (optional) the second of the minute (`0` through `59`) to set 2014 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2015 | * @return self the new instance 2016 | */ 2017 | public static function fromDateTime($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timeZone = null) { 2018 | return self::now($timeZone)->withDate($year, $month, $day)->withTime($hour, $minute, $second); 2019 | } 2020 | 2021 | /** 2022 | * Creates a new instance with the specified date 2023 | * 2024 | * Any component that is not set (and the time) will be set to "now" 2025 | * 2026 | * @param int|null $year (optional) the year to set 2027 | * @param int|null $month (optional) the month of the year (`1` through `12`) to set 2028 | * @param int|null $day (optional) the day of the month (`1` through `31`) to set 2029 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2030 | * @return self the new instance 2031 | */ 2032 | public static function fromDate($year = null, $month = null, $day = null, $timeZone = null) { 2033 | return self::now($timeZone)->withDate($year, $month, $day); 2034 | } 2035 | 2036 | /** 2037 | * Creates a new instance with the specified time 2038 | * 2039 | * Any component that is not set (and the date) will be set to "now" 2040 | * 2041 | * @param int|null $hour (optional) the hour of the day (`0` through `23`) to set 2042 | * @param int|null $minute (optional) the minute of the hour (`0` through `59`) to set 2043 | * @param int|null $second (optional) the second of the minute (`0` through `59`) to set 2044 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2045 | * @return self the new instance 2046 | */ 2047 | public static function fromTime($hour = null, $minute = null, $second = null, $timeZone = null) { 2048 | return self::now($timeZone)->withTime($hour, $minute, $second); 2049 | } 2050 | 2051 | /** 2052 | * Creates a new instance by parsing the supplied input as defined in the specified format 2053 | * 2054 | * @param string $dateTime the input to validate and parse as defined in the specified format 2055 | * @param string $format the format of the input, described using the formatting options of {@see \date} 2056 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2057 | * @return self the new instance 2058 | */ 2059 | public static function fromFormat($dateTime, $format, $timeZone = null) { 2060 | return self::createInstanceFromFormat($format, $dateTime, $timeZone); 2061 | } 2062 | 2063 | /** 2064 | * Creates a new instance from the supplied {@see \DateTimeInterface} instance 2065 | * 2066 | * @param \DateTimeInterface $dateTimeInterface the {@see \DateTime} or {@see \DateTimeImmutable} instance 2067 | * @return self the new instance 2068 | */ 2069 | public static function fromDateTimeInterface(\DateTimeInterface $dateTimeInterface) { 2070 | $instance = new self(); 2071 | 2072 | $instance->dateTime = \DateTime::createFromFormat( 2073 | Unix::FORMAT_FLOAT, 2074 | $dateTimeInterface->format(Unix::FORMAT_FLOAT), 2075 | $dateTimeInterface->getTimezone() 2076 | ); 2077 | 2078 | return $instance; 2079 | } 2080 | 2081 | /** 2082 | * Creates a new instance with yesterday's date 2083 | * 2084 | * The time is set to the current time 2085 | * 2086 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2087 | * @return self the new instance 2088 | */ 2089 | public static function yesterday($timeZone = null) { 2090 | return self::now($timeZone)->minusDays(1); 2091 | } 2092 | 2093 | /** 2094 | * Creates a new instance with the current date and time 2095 | * 2096 | * Alias of {@see now} 2097 | * 2098 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2099 | * @return self the new instance 2100 | */ 2101 | public static function today($timeZone = null) { 2102 | return self::now($timeZone); 2103 | } 2104 | 2105 | /** 2106 | * Creates a new instance with tomorrow's date 2107 | * 2108 | * The time is set to the current time 2109 | * 2110 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2111 | * @return self the new instance 2112 | */ 2113 | public static function tomorrow($timeZone = null) { 2114 | return self::now($timeZone)->plusDays(1); 2115 | } 2116 | 2117 | /** 2118 | * Returns whether a current mock time has been set for debugging and testing 2119 | * 2120 | * @return bool 2121 | */ 2122 | public static function hasMockNow() { 2123 | return self::$mockNow !== null; 2124 | } 2125 | 2126 | /** 2127 | * Returns the current mock time (if set) that may be used for debugging and testing 2128 | * 2129 | * @return self|null the instance or `null` if not set 2130 | */ 2131 | public static function getMockNow() { 2132 | return self::$mockNow; 2133 | } 2134 | 2135 | /** 2136 | * Sets (or unsets) the current mock time that may be used for debugging and testing 2137 | * 2138 | * @param self|null $mockNow the instance to set or `null` to unset 2139 | */ 2140 | public static function setMockNow(self $mockNow = null) { 2141 | self::$mockNow = $mockNow; 2142 | } 2143 | 2144 | /** 2145 | * Returns the significand of the decade 2146 | * 2147 | * @return int 2148 | */ 2149 | private function getDecadeSignificand() { 2150 | return self::intdiv($this->getYear(), 10); 2151 | } 2152 | 2153 | /** 2154 | * Returns the significand of the century 2155 | * 2156 | * @return int 2157 | */ 2158 | private function getCenturySignificand() { 2159 | return self::intdiv($this->getYear(), 100); 2160 | } 2161 | 2162 | /** 2163 | * Returns the significand of the millennium 2164 | * 2165 | * @return int 2166 | */ 2167 | private function getMillenniumSignificand() { 2168 | return self::intdiv($this->getYear(), 1000); 2169 | } 2170 | 2171 | /** 2172 | * Applies the specified duration as per ISO 8601 2173 | * 2174 | * @param string $duration the duration as per ISO 8601 2175 | * @param string $dateTimeInstanceMethodName the method to call on the {@see \DateTime} instance 2176 | * @return self a new instance 2177 | */ 2178 | private function withIso8601DurationApplied($duration, $dateTimeInstanceMethodName) { 2179 | $copy = $this->copy(); 2180 | 2181 | $copy->dateTime->$dateTimeInstanceMethodName( 2182 | new \DateInterval($duration) 2183 | ); 2184 | 2185 | if (Iso8601Duration::affectsMonthsOnly($duration)) { 2186 | // if the *actual* day does not exist in the *intended* month which causes PHP to calculate *wrongly* 2187 | if ($copy->getDay() !== $this->getDay()) { 2188 | // fix the calculation retroactively 2189 | $copy = $copy->withModification('last day of previous month'); 2190 | } 2191 | } 2192 | 2193 | return $copy; 2194 | } 2195 | 2196 | /** 2197 | * Changes the date and/or time as prescribed by the supplied string 2198 | * 2199 | * @link http://php.net/manual/en/datetime.formats.php 2200 | * 2201 | * @param string $modification the modification as understood by {@see \strtotime} to apply 2202 | * @return self a new instance 2203 | */ 2204 | private function withModification($modification) { 2205 | $copy = $this->copy(); 2206 | 2207 | $copy->dateTime->modify($modification); 2208 | 2209 | return $copy; 2210 | } 2211 | 2212 | /** 2213 | * Changes the time zone to that with the specified identifier 2214 | * 2215 | * Passing `null` will set the default time zone 2216 | * 2217 | * @param string|null $identifier the identifier of the time zone to use (e.g. `Asia/Tokyo`) or `null` 2218 | * @return self the modified instance 2219 | */ 2220 | private function setTimeZone($identifier = null) { 2221 | return $this->setTimeZoneInstance( 2222 | self::makeTimeZone($identifier) 2223 | ); 2224 | } 2225 | 2226 | /** 2227 | * Changes the time zone to the supplied one 2228 | * 2229 | * @param \DateTimeZone $timeZone the time zone to use 2230 | * @return self the modified instance 2231 | */ 2232 | private function setTimeZoneInstance(\DateTimeZone $timeZone) { 2233 | $this->dateTime->setTimezone($timeZone); 2234 | 2235 | return $this; 2236 | } 2237 | 2238 | /** Do not allow direct instantiation */ 2239 | private function __construct() {} 2240 | 2241 | /** 2242 | * Compares the two supplied instances with respect to the specified precision 2243 | * 2244 | * The basic format of ISO 8601 with date and time is used for the comparison 2245 | * 2246 | * @see toIso8601DateTimeBasic 2247 | * 2248 | * @param self $a the first instance 2249 | * @param self $b the second instance 2250 | * @param int $substringPrecision the number of characters to compare (between 1 and 15) 2251 | * @return int whether the first instance is less than (< 0), equal to (0) or greater than (> 0) the second 2252 | */ 2253 | private static function compareInstances(self $a, self $b, $substringPrecision) { 2254 | $substringPrecision = (int) $substringPrecision; 2255 | 2256 | return \strcasecmp( 2257 | \substr($a->toIso8601DateTimeBasic(), 0, $substringPrecision), 2258 | \substr($b->toIso8601DateTimeBasic(), 0, $substringPrecision) 2259 | ); 2260 | } 2261 | 2262 | /** 2263 | * Creates a new instance by parsing the supplied input as defined in the specified format 2264 | * 2265 | * @param string $format the format of the input, described using the formatting options of {@see \date} 2266 | * @param string $dateTime the input to validate and parse as defined in the specified format 2267 | * @param string|null $timeZone (optional) the identifier of the time zone to use (e.g. `Asia/Tokyo`) 2268 | * @return self the new instance 2269 | * @throws InvalidDateTimeFormatError if the date and/or time has been invalid with respect to the format 2270 | */ 2271 | private static function createInstanceFromFormat($format, $dateTime, $timeZone = null) { 2272 | $timeZoneInstance = self::makeTimeZone($timeZone); 2273 | 2274 | $parsed = \DateTime::createFromFormat( 2275 | $format, 2276 | $dateTime, 2277 | $timeZoneInstance 2278 | ); 2279 | 2280 | if ($parsed === false) { 2281 | throw new InvalidDateTimeFormatError(); 2282 | } 2283 | else { 2284 | return self::createInstance($parsed)->setTimeZoneInstance($timeZoneInstance); 2285 | } 2286 | } 2287 | 2288 | /** 2289 | * Creates a new instance with the supplied object as the representation of date and/or time 2290 | * 2291 | * @param \DateTime $dateTime the representation of date and/or time 2292 | * @return self the new instance 2293 | */ 2294 | private static function createInstance(\DateTime $dateTime) { 2295 | $instance = new self(); 2296 | 2297 | $instance->dateTime = $dateTime; 2298 | 2299 | return $instance; 2300 | } 2301 | 2302 | /** 2303 | * Creates an instance for the specified time zone 2304 | * 2305 | * Passing `null` will create an instance of the default time zone 2306 | * 2307 | * @param string|null $identifier the identifier of the time zone (e.g. `Asia/Tokyo`) or `null` 2308 | * @return \DateTimeZone|null the new instance 2309 | * @throws InvalidTimeZoneIdentifierError if the time zone identifier has been invalid 2310 | */ 2311 | private static function makeTimeZone($identifier = null) { 2312 | try { 2313 | return new \DateTimeZone( 2314 | $identifier !== null ? $identifier : \date_default_timezone_get() 2315 | ); 2316 | } 2317 | catch (\Exception $e) { 2318 | throw new InvalidTimeZoneIdentifierError(); 2319 | } 2320 | } 2321 | 2322 | /** 2323 | * Returns the integer quotient of the two supplied numbers 2324 | * 2325 | * @param int $dividend 2326 | * @param int $divisor 2327 | * @return int 2328 | */ 2329 | private static function intdiv($dividend, $divisor) { 2330 | return ($dividend - ($dividend % $divisor)) / $divisor; 2331 | } 2332 | 2333 | /** 2334 | * Returns the sign of the given number 2335 | * 2336 | * @param int $number 2337 | * @return int the sign (`-1` for negative numbers, `0` for zero and `1` for positive numbers) 2338 | */ 2339 | private static function signum($number) { 2340 | return $number > 0 ? 1 : ($number < 0 ? -1 : 0); 2341 | } 2342 | 2343 | } 2344 | -------------------------------------------------------------------------------- /src/Throwable/Error.php: -------------------------------------------------------------------------------- 1 | withTime(12, 30, 30), '1855-06-15T12:30:30-08:00', __LINE__); 54 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601Date('1855-06-15', 'Europe/Vienna')->withTime(21, 30, 30), '1855-06-15T21:30:30+01:00', __LINE__); 55 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601DateExtended('1855-06-15')->withTime(12, 30, 30), '1855-06-15T12:30:30-08:00', __LINE__); 56 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601DateExtended('1855-06-15', 'Europe/Vienna')->withTime(21, 30, 30), '1855-06-15T21:30:30+01:00', __LINE__); 57 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601DateBasic('18550615')->withTime(12, 30, 30), '1855-06-15T12:30:30-08:00', __LINE__); 58 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601DateBasic('18550615', 'Europe/Vienna')->withTime(21, 30, 30), '1855-06-15T21:30:30+01:00', __LINE__); 59 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601Time('12:30:30-08:00')->withDate(1855, 6, 15)->minusHours(1), '1855-06-15T12:30:30-08:00', __LINE__); 60 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601Time('12:30:30-08:00', 'Europe/Vienna')->withDate(1855, 6, 15)->minusHours(1), '1855-06-15T21:30:30+01:00', __LINE__); 61 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601TimeExtended('12:30:30-08:00')->withDate(1855, 6, 15)->minusHours(1), '1855-06-15T12:30:30-08:00', __LINE__); 62 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601TimeExtended('12:30:30-08:00', 'Europe/Vienna')->withDate(1855, 6, 15)->minusHours(1), '1855-06-15T21:30:30+01:00', __LINE__); 63 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601TimeBasic('123030-0800')->withDate(1855, 6, 15)->minusHours(1), '1855-06-15T12:30:30-08:00', __LINE__); 64 | assertSame((string) \Delight\Temporal\Temporal::fromIso8601TimeBasic('123030-0800', 'Europe/Vienna')->withDate(1855, 6, 15)->minusHours(1), '1855-06-15T21:30:30+01:00', __LINE__); 65 | assertSame((string) \Delight\Temporal\Temporal::fromDateTime(1855, 6, 15, 12, 30, 30), '1855-06-15T12:30:30-08:00', __LINE__); 66 | assertSame((string) \Delight\Temporal\Temporal::fromDateTime(1855, 6, 15, 21, 30, 30, 'Europe/Vienna'), '1855-06-15T21:30:30+01:00', __LINE__); 67 | assertSame((string) \Delight\Temporal\Temporal::fromDate(1855, 6, 15), '1855-06-15T12:30:30-08:00', __LINE__); 68 | assertSame((string) \Delight\Temporal\Temporal::fromDate(1855, 6, 15, 'Europe/Vienna'), '1855-06-15T21:30:30+01:00', __LINE__); 69 | assertSame((string) \Delight\Temporal\Temporal::fromTime(12, 30, 30), '1855-06-15T12:30:30-08:00', __LINE__); 70 | assertSame((string) \Delight\Temporal\Temporal::fromTime(21, 30, 30, 'Europe/Vienna'), '1855-06-15T21:30:30+01:00', __LINE__); 71 | assertSame((string) \Delight\Temporal\Temporal::fromFormat('15.06.1855 12:30:30', 'd.m.Y H:i:s'), '1855-06-15T12:30:30-08:00', __LINE__); 72 | assertSame((string) \Delight\Temporal\Temporal::fromFormat('15.06.1855 21:30:30', 'd.m.Y H:i:s', 'Europe/Vienna'), '1855-06-15T21:30:30+01:00', __LINE__); 73 | 74 | assertSame(\Delight\Temporal\Temporal::fromDateTimeInterface($plainDateTime)->toUnixSeconds(), (int) $plainDateTime->format('U'), __LINE__); 75 | assertSame(\Delight\Temporal\Temporal::fromDateTimeInterface($plainDateTime)->plusSeconds(5)->toUnixSeconds(), (int) $plainDateTime->format('U') + 5, __LINE__); 76 | assertSame(\Delight\Temporal\Temporal::fromDateTimeInterface($plainDateTime)->minusSeconds(42)->toUnixSeconds(), (int) $plainDateTime->format('U') - 42, __LINE__); 77 | assertSame(\Delight\Temporal\Temporal::fromDateTimeInterface($plainDateTimeImmutable)->toUnixSeconds(), (int) $plainDateTimeImmutable->format('U'), __LINE__); 78 | assertSame(\Delight\Temporal\Temporal::fromDateTimeInterface($plainDateTimeImmutable)->plusSeconds(5)->toUnixSeconds(), (int) $plainDateTimeImmutable->format('U') + 5, __LINE__); 79 | assertSame(\Delight\Temporal\Temporal::fromDateTimeInterface($plainDateTimeImmutable)->minusSeconds(42)->toUnixSeconds(), (int) $plainDateTimeImmutable->format('U') - 42, __LINE__); 80 | 81 | assertSame((string) \Delight\Temporal\Temporal::yesterday()->plusDays(1), '1855-06-15T12:30:30-08:00', __LINE__); 82 | assertSame((string) \Delight\Temporal\Temporal::yesterday('Europe/Vienna')->plusDays(1), '1855-06-15T21:30:30+01:00', __LINE__); 83 | assertSame((string) \Delight\Temporal\Temporal::today(), '1855-06-15T12:30:30-08:00', __LINE__); 84 | assertSame((string) \Delight\Temporal\Temporal::today('Europe/Vienna'), '1855-06-15T21:30:30+01:00', __LINE__); 85 | assertSame((string) \Delight\Temporal\Temporal::tomorrow()->minusDays(1), '1855-06-15T12:30:30-08:00', __LINE__); 86 | assertSame((string) \Delight\Temporal\Temporal::tomorrow('Europe/Vienna')->minusDays(1), '1855-06-15T21:30:30+01:00', __LINE__); 87 | 88 | assertSame((string) $now, '1855-06-15T12:30:30-08:00', __LINE__); 89 | assertSame((string) $now, (string) \Delight\Temporal\Temporal::today(), __LINE__); 90 | assertSame((string) $declarationOfIndependence, '1776-07-04T12:30:30-08:00', __LINE__); 91 | assertSame((string) $moonLanding, '1969-07-20T13:18:04-07:00', __LINE__); 92 | assertSame((string) $moonLanding->withTimeZone('Africa/Nairobi'), (string) \Delight\Temporal\Temporal::fromIso8601DateTime('1969-07-20T20:18:04+00:00', 'Africa/Nairobi'), __LINE__); 93 | assertSame((string) $moonLanding->withTimeZone('Africa/Nairobi'), (string) \Delight\Temporal\Temporal::fromIso8601DateTimeExtended('1969-07-20T20:18:04Z', 'Africa/Nairobi'), __LINE__); 94 | assertSame((string) $moonLanding->withTimeZone('Africa/Nairobi'), (string) \Delight\Temporal\Temporal::fromIso8601DateTimeBasic('19690720T201804+0000', 'Africa/Nairobi'), __LINE__); 95 | assertSame($moonLanding->toIso8601DateExtended(), \Delight\Temporal\Temporal::fromIso8601Date('1969-07-20')->toIso8601DateExtended(), __LINE__); 96 | assertSame($moonLanding->toIso8601DateExtended(), \Delight\Temporal\Temporal::fromIso8601DateExtended('1969-07-20')->toIso8601DateExtended(), __LINE__); 97 | assertSame($moonLanding->toIso8601DateExtended(), \Delight\Temporal\Temporal::fromIso8601DateBasic('19690720')->toIso8601DateExtended(), __LINE__); 98 | assertSame($moonLanding->withTimeZone('Africa/Nairobi')->toIso8601TimeExtended(), \Delight\Temporal\Temporal::fromIso8601Time('20:18:04+00:00', 'Africa/Nairobi')->toIso8601TimeExtended(), __LINE__); 99 | assertSame($moonLanding->toIso8601TimeExtended(), \Delight\Temporal\Temporal::fromIso8601TimeExtended('20:18:04Z')->toIso8601TimeExtended(), __LINE__); 100 | assertSame($moonLanding->toIso8601TimeExtended(), \Delight\Temporal\Temporal::fromIso8601TimeBasic('201804+0000')->toIso8601TimeExtended(), __LINE__); 101 | assertSame($moonLanding->withTimeZone('Africa/Nairobi')->toIso8601TimeBasic(), \Delight\Temporal\Temporal::fromIso8601Time('20:18:04+00:00', 'Africa/Nairobi')->toIso8601TimeBasic(), __LINE__); 102 | assertSame($moonLanding->toIso8601TimeBasic(), \Delight\Temporal\Temporal::fromIso8601TimeExtended('20:18:04Z')->toIso8601TimeBasic(), __LINE__); 103 | assertSame($moonLanding->toIso8601TimeBasic(), \Delight\Temporal\Temporal::fromIso8601TimeBasic('201804+0000')->toIso8601TimeBasic(), __LINE__); 104 | assertSame($moonLanding->toFormat('d.m.Y H:i:s'), '20.07.1969 13:18:04', __LINE__); 105 | assertSame($moonLanding->toFormat('d.m.Y H:i:s P'), '20.07.1969 13:18:04 -07:00', __LINE__); 106 | 107 | assertSame($smallStepForMan->toDateTime() instanceof \DateTime, true, __LINE__); 108 | assertSame($smallStepForMan->toDateTime() instanceof \DateTimeInterface, true, __LINE__); 109 | assertSame($smallStepForMan->toDateTime() instanceof \DateTimeImmutable, false, __LINE__); 110 | assertSame((int) $smallStepForMan->toDateTime()->format('U'), $smallStepForMan->toUnixSeconds(), __LINE__); 111 | assertSame((int) $smallStepForMan->toDateTime()->modify('+42 days')->format('U'), $smallStepForMan->plusDays(42)->toUnixSeconds(), __LINE__); 112 | assertSame((int) $smallStepForMan->toDateTime()->modify('-42 minutes')->format('U'), $smallStepForMan->minusMinutes(42)->toUnixSeconds(), __LINE__); 113 | assertSame($smallStepForMan->toDateTimeImmutable() instanceof \DateTime, false, __LINE__); 114 | assertSame($smallStepForMan->toDateTimeImmutable() instanceof \DateTimeInterface, true, __LINE__); 115 | assertSame($smallStepForMan->toDateTimeImmutable() instanceof \DateTimeImmutable, true, __LINE__); 116 | assertSame((int) $smallStepForMan->toDateTimeImmutable()->format('U'), $smallStepForMan->toUnixSeconds(), __LINE__); 117 | assertSame((int) $smallStepForMan->toDateTimeImmutable()->modify('+42 days')->format('U'), $smallStepForMan->plusDays(42)->toUnixSeconds(), __LINE__); 118 | assertSame((int) $smallStepForMan->toDateTimeImmutable()->modify('-42 minutes')->format('U'), $smallStepForMan->minusMinutes(42)->toUnixSeconds(), __LINE__); 119 | 120 | assertSame((string) $smallStepForMan, '1969-07-20T19:56:15-07:00', __LINE__); 121 | assertSame((string) $yesterday, '1855-06-14T12:30:30-08:00', __LINE__); 122 | assertSame((string) $quarterPastMidnight, '1855-06-15T00:15:00-08:00', __LINE__); 123 | assertSame((string) $tomorrow, '1855-06-16T12:30:30-08:00', __LINE__); 124 | assertSame((string) $problem2038->withTimeZone('UTC'), '2038-01-19T03:14:07+00:00', __LINE__); 125 | 126 | assertSame((string) $moonLanding->plusYears(1), '1970-07-20T13:18:04-07:00', __LINE__); 127 | assertSame((string) $moonLanding->plusYears(42), '2011-07-20T13:18:04-07:00', __LINE__); 128 | assertSame((string) $moonLanding->plusMonths(1), '1969-08-20T13:18:04-07:00', __LINE__); 129 | assertSame((string) $moonLanding->plusMonths(42), '1973-01-20T13:18:04-08:00', __LINE__); 130 | assertSame((string) $moonLanding->plusWeeks(1), '1969-07-27T13:18:04-07:00', __LINE__); 131 | assertSame((string) $moonLanding->plusWeeks(42), '1970-05-10T13:18:04-07:00', __LINE__); 132 | assertSame((string) $moonLanding->plusDays(1), '1969-07-21T13:18:04-07:00', __LINE__); 133 | assertSame((string) $moonLanding->plusDays(42), '1969-08-31T13:18:04-07:00', __LINE__); 134 | assertSame((string) $moonLanding->plusHours(1), '1969-07-20T14:18:04-07:00', __LINE__); 135 | assertSame((string) $moonLanding->plusHours(84), '1969-07-24T01:18:04-07:00', __LINE__); 136 | assertSame((string) $moonLanding->plusMinutes(1), '1969-07-20T13:19:04-07:00', __LINE__); 137 | assertSame((string) $moonLanding->plusMinutes(84), '1969-07-20T14:42:04-07:00', __LINE__); 138 | assertSame((string) $moonLanding->plusSeconds(1), '1969-07-20T13:18:05-07:00', __LINE__); 139 | assertSame((string) $moonLanding->plusSeconds(84), '1969-07-20T13:19:28-07:00', __LINE__); 140 | assertSame((string) $moonLanding->plusIso8601Duration('P2Y'), '1971-07-20T13:18:04-07:00', __LINE__); 141 | assertSame((string) $moonLanding->plusIso8601Duration('P3M'), '1969-10-20T13:18:04-07:00', __LINE__); 142 | assertSame((string) $moonLanding->plusIso8601Duration('P12M'), '1970-07-20T13:18:04-07:00', __LINE__); 143 | assertSame((string) $moonLanding->plusIso8601Duration('P14M'), '1970-09-20T13:18:04-07:00', __LINE__); 144 | assertSame((string) $moonLanding->plusIso8601Duration('P4D'), '1969-07-24T13:18:04-07:00', __LINE__); 145 | assertSame((string) $moonLanding->plusIso8601Duration('P8D'), '1969-07-28T13:18:04-07:00', __LINE__); 146 | assertSame((string) $moonLanding->plusIso8601Duration('P32D'), '1969-08-21T13:18:04-07:00', __LINE__); 147 | assertSame((string) $moonLanding->plusIso8601Duration('PT5H'), '1969-07-20T18:18:04-07:00', __LINE__); 148 | assertSame((string) $moonLanding->plusIso8601Duration('PT23H'), '1969-07-21T12:18:04-07:00', __LINE__); 149 | assertSame((string) $moonLanding->plusIso8601Duration('PT36H'), '1969-07-22T01:18:04-07:00', __LINE__); 150 | assertSame((string) $moonLanding->plusIso8601Duration('PT6M'), '1969-07-20T13:24:04-07:00', __LINE__); 151 | assertSame((string) $moonLanding->plusIso8601Duration('PT64M'), '1969-07-20T14:22:04-07:00', __LINE__); 152 | assertSame((string) $moonLanding->plusIso8601Duration('PT7S'), '1969-07-20T13:18:11-07:00', __LINE__); 153 | assertSame((string) $moonLanding->plusIso8601Duration('PT72S'), '1969-07-20T13:19:16-07:00', __LINE__); 154 | assertSame((string) $moonLanding->plusIso8601Duration('P1DT12H'), '1969-07-22T01:18:04-07:00', __LINE__); 155 | assertSame((string) $moonLanding->plusIso8601Duration('P23DT23H'), '1969-08-13T12:18:04-07:00', __LINE__); 156 | assertSame((string) $moonLanding->plusIso8601Duration('P6M'), '1970-01-20T13:18:04-08:00', __LINE__); 157 | 158 | assertSame((string) $moonLanding->minusYears(1), '1968-07-20T13:18:04-07:00', __LINE__); 159 | assertSame((string) $moonLanding->minusYears(42), '1927-07-20T13:18:04-08:00', __LINE__); 160 | assertSame((string) $moonLanding->minusMonths(1), '1969-06-20T13:18:04-07:00', __LINE__); 161 | assertSame((string) $moonLanding->minusMonths(42), '1966-01-20T13:18:04-08:00', __LINE__); 162 | assertSame((string) $moonLanding->minusWeeks(1), '1969-07-13T13:18:04-07:00', __LINE__); 163 | assertSame((string) $moonLanding->minusWeeks(42), '1968-09-29T13:18:04-07:00', __LINE__); 164 | assertSame((string) $moonLanding->minusDays(1), '1969-07-19T13:18:04-07:00', __LINE__); 165 | assertSame((string) $moonLanding->minusDays(42), '1969-06-08T13:18:04-07:00', __LINE__); 166 | assertSame((string) $moonLanding->minusHours(1), '1969-07-20T12:18:04-07:00', __LINE__); 167 | assertSame((string) $moonLanding->minusHours(84), '1969-07-17T01:18:04-07:00', __LINE__); 168 | assertSame((string) $moonLanding->minusMinutes(1), '1969-07-20T13:17:04-07:00', __LINE__); 169 | assertSame((string) $moonLanding->minusMinutes(84), '1969-07-20T11:54:04-07:00', __LINE__); 170 | assertSame((string) $moonLanding->minusSeconds(1), '1969-07-20T13:18:03-07:00', __LINE__); 171 | assertSame((string) $moonLanding->minusSeconds(84), '1969-07-20T13:16:40-07:00', __LINE__); 172 | assertSame((string) $moonLanding->minusIso8601Duration('P2Y'), '1967-07-20T13:18:04-07:00', __LINE__); 173 | assertSame((string) $moonLanding->minusIso8601Duration('P3M'), '1969-04-20T13:18:04-08:00', __LINE__); 174 | assertSame((string) $moonLanding->minusIso8601Duration('P12M'), '1968-07-20T13:18:04-07:00', __LINE__); 175 | assertSame((string) $moonLanding->minusIso8601Duration('P14M'), '1968-05-20T13:18:04-07:00', __LINE__); 176 | assertSame((string) $moonLanding->minusIso8601Duration('P4D'), '1969-07-16T13:18:04-07:00', __LINE__); 177 | assertSame((string) $moonLanding->minusIso8601Duration('P8D'), '1969-07-12T13:18:04-07:00', __LINE__); 178 | assertSame((string) $moonLanding->minusIso8601Duration('P32D'), '1969-06-18T13:18:04-07:00', __LINE__); 179 | assertSame((string) $moonLanding->minusIso8601Duration('PT5H'), '1969-07-20T08:18:04-07:00', __LINE__); 180 | assertSame((string) $moonLanding->minusIso8601Duration('PT23H'), '1969-07-19T14:18:04-07:00', __LINE__); 181 | assertSame((string) $moonLanding->minusIso8601Duration('PT36H'), '1969-07-19T01:18:04-07:00', __LINE__); 182 | assertSame((string) $moonLanding->minusIso8601Duration('PT6M'), '1969-07-20T13:12:04-07:00', __LINE__); 183 | assertSame((string) $moonLanding->minusIso8601Duration('PT64M'), '1969-07-20T12:14:04-07:00', __LINE__); 184 | assertSame((string) $moonLanding->minusIso8601Duration('PT7S'), '1969-07-20T13:17:57-07:00', __LINE__); 185 | assertSame((string) $moonLanding->minusIso8601Duration('PT72S'), '1969-07-20T13:16:52-07:00', __LINE__); 186 | assertSame((string) $moonLanding->minusIso8601Duration('P1DT12H'), '1969-07-19T01:18:04-07:00', __LINE__); 187 | assertSame((string) $moonLanding->minusIso8601Duration('P23DT23H'), '1969-06-26T14:18:04-07:00', __LINE__); 188 | assertSame((string) $moonLanding->minusIso8601Duration('P6M'), '1969-01-20T13:18:04-08:00', __LINE__); 189 | 190 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 28)->plusMonths(1)->toIso8601DateBasic(), '20170228', __LINE__); 191 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 31)->plusMonths(1)->toIso8601DateBasic(), '20170228', __LINE__); 192 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 28)->plusMonths(2)->toIso8601DateBasic(), '20170328', __LINE__); 193 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 31)->plusMonths(2)->toIso8601DateBasic(), '20170331', __LINE__); 194 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 28)->plusMonths(3)->toIso8601DateBasic(), '20170428', __LINE__); 195 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 31)->plusMonths(3)->toIso8601DateBasic(), '20170430', __LINE__); 196 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 28)->minusMonths(3)->toIso8601DateBasic(), '20170228', __LINE__); 197 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 31)->minusMonths(3)->toIso8601DateBasic(), '20170228', __LINE__); 198 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 28)->minusMonths(2)->toIso8601DateBasic(), '20170328', __LINE__); 199 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 31)->minusMonths(2)->toIso8601DateBasic(), '20170331', __LINE__); 200 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 28)->minusMonths(1)->toIso8601DateBasic(), '20170428', __LINE__); 201 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 31)->minusMonths(1)->toIso8601DateBasic(), '20170430', __LINE__); 202 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 28)->plusIso8601Duration('P1M')->toIso8601DateBasic(), '20170228', __LINE__); 203 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 31)->plusIso8601Duration('P1M')->toIso8601DateBasic(), '20170228', __LINE__); 204 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 28)->plusIso8601Duration('P2M')->toIso8601DateBasic(), '20170328', __LINE__); 205 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 31)->plusIso8601Duration('P2M')->toIso8601DateBasic(), '20170331', __LINE__); 206 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 28)->plusIso8601Duration('P3M')->toIso8601DateBasic(), '20170428', __LINE__); 207 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 1, 31)->plusIso8601Duration('P3M')->toIso8601DateBasic(), '20170430', __LINE__); 208 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 28)->minusIso8601Duration('P3M')->toIso8601DateBasic(), '20170228', __LINE__); 209 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 31)->minusIso8601Duration('P3M')->toIso8601DateBasic(), '20170228', __LINE__); 210 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 28)->minusIso8601Duration('P2M')->toIso8601DateBasic(), '20170328', __LINE__); 211 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 31)->minusIso8601Duration('P2M')->toIso8601DateBasic(), '20170331', __LINE__); 212 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 28)->minusIso8601Duration('P1M')->toIso8601DateBasic(), '20170428', __LINE__); 213 | assertSame(\Delight\Temporal\Temporal::fromDate(2017, 5, 31)->minusIso8601Duration('P1M')->toIso8601DateBasic(), '20170430', __LINE__); 214 | 215 | assertSame($moonLanding->getYear(), 1969, __LINE__); 216 | assertSame($moonLanding->getMonth(), 7, __LINE__); 217 | assertSame($moonLanding->getDay(), 20, __LINE__); 218 | assertSame($moonLanding->withTimeZone('Australia/Melbourne')->getDay(), 21, __LINE__); 219 | assertSame($moonLanding->getHour(), 13, __LINE__); 220 | assertSame($moonLanding->getMinute(), 18, __LINE__); 221 | assertSame($moonLanding->getSecond(), 4, __LINE__); 222 | assertSame($moonLanding->getWeekday(), \Delight\Temporal\Iso8601\Iso8601Weekday::SUNDAY, __LINE__); 223 | assertSame($moonLanding->withTimeZone('Australia/Sydney')->getWeekday(), \Delight\Temporal\Iso8601\Iso8601Weekday::MONDAY, __LINE__); 224 | assertSame($moonLanding->isMonday(), false, __LINE__); 225 | assertSame($moonLanding->isTuesday(), false, __LINE__); 226 | assertSame($moonLanding->isWednesday(), false, __LINE__); 227 | assertSame($moonLanding->isThursday(), false, __LINE__); 228 | assertSame($moonLanding->isFriday(), false, __LINE__); 229 | assertSame($moonLanding->isSaturday(), false, __LINE__); 230 | assertSame($moonLanding->isSunday(), true, __LINE__); 231 | assertSame($moonLanding->plusDays(3)->isMonday(), false, __LINE__); 232 | assertSame($moonLanding->plusDays(3)->isTuesday(), false, __LINE__); 233 | assertSame($moonLanding->plusDays(3)->isWednesday(), true, __LINE__); 234 | assertSame($moonLanding->plusDays(3)->isThursday(), false, __LINE__); 235 | assertSame($moonLanding->plusDays(3)->isFriday(), false, __LINE__); 236 | assertSame($moonLanding->plusDays(3)->isSaturday(), false, __LINE__); 237 | assertSame($moonLanding->plusDays(3)->isSunday(), false, __LINE__); 238 | assertSame($moonLanding->getWeekOfYear(), 29, __LINE__); 239 | assertSame($moonLanding->getWeekYear(), 1969, __LINE__); 240 | assertSame($moonLanding->getDayOfYear(), 201, __LINE__); 241 | 242 | assertSame((string) $moonLanding->withYear(1984), '1984-07-20T13:18:04-07:00', __LINE__); 243 | assertSame((string) $moonLanding->withMonth(12), '1969-12-20T13:18:04-08:00', __LINE__); 244 | assertSame((string) $moonLanding->withDay(24), '1969-07-24T13:18:04-07:00', __LINE__); 245 | assertSame((string) $moonLanding->withDate(1989, 11, 9), '1989-11-09T13:18:04-08:00', __LINE__); 246 | assertSame((string) $moonLanding->withHour(12), '1969-07-20T12:18:04-07:00', __LINE__); 247 | assertSame((string) $moonLanding->withMinute(30), '1969-07-20T13:30:04-07:00', __LINE__); 248 | assertSame((string) $moonLanding->withSecond(45), '1969-07-20T13:18:45-07:00', __LINE__); 249 | assertSame((string) $moonLanding->withTime(19, 4, 30), '1969-07-20T19:04:30-07:00', __LINE__); 250 | assertSame((string) $moonLanding->withYear(1989)->withMonth(10), '1989-10-20T13:18:04-07:00', __LINE__); 251 | assertSame((string) $moonLanding->withYear(1989)->withSecond(52), '1989-07-20T13:18:52-07:00', __LINE__); 252 | 253 | assertSame($moonLanding->toIso8601DateTime(), $moonLanding->toIso8601DateTimeExtended(), __LINE__); 254 | assertSame($smallStepForMan->toIso8601DateTime(), $smallStepForMan->toIso8601DateTimeExtended(), __LINE__); 255 | assertSame($moonLanding->toIso8601DateTimeExtended(), '1969-07-20T13:18:04-07:00', __LINE__); 256 | assertSame($moonLanding->withDefaultTimeZone()->toIso8601DateTimeExtended(), $moonLanding->toIso8601DateTimeExtended(), __LINE__); 257 | assertSame($moonLanding->withTimeZone('UTC')->toIso8601DateTimeExtended(), '1969-07-20T20:18:04+00:00', __LINE__); 258 | assertSame($moonLanding->withTimeZone('Australia/Melbourne')->toIso8601DateTimeExtended(), '1969-07-21T06:18:04+10:00', __LINE__); 259 | assertSame($smallStepForMan->toIso8601DateTimeExtended(), '1969-07-20T19:56:15-07:00', __LINE__); 260 | assertSame($smallStepForMan->withDefaultTimeZone()->toIso8601DateTimeExtended(), $smallStepForMan->toIso8601DateTimeExtended(), __LINE__); 261 | assertSame($smallStepForMan->withTimeZone('UTC')->toIso8601DateTimeExtended(), '1969-07-21T02:56:15+00:00', __LINE__); 262 | assertSame($smallStepForMan->withTimeZone('Australia/Melbourne')->toIso8601DateTimeExtended(), '1969-07-21T12:56:15+10:00', __LINE__); 263 | assertSame($moonLanding->toIso8601DateTimeBasic(), '19690720T131804-0700', __LINE__); 264 | assertSame($smallStepForMan->toIso8601DateTimeBasic(), '19690720T195615-0700', __LINE__); 265 | 266 | assertSame($moonLanding->toUnixSeconds(), \strtotime('July 20 1969 20:18:04 UTC'), __LINE__); 267 | assertSame($moonLanding->toUnixMillis(), $moonLanding->toUnixSeconds() * 1000, __LINE__); 268 | assertSame($smallStepForMan->toUnixSeconds(), \strtotime('July 21 1969 02:56:15 UTC'), __LINE__); 269 | assertSame($smallStepForMan->toUnixMillis(), $smallStepForMan->toUnixSeconds() * 1000, __LINE__); 270 | 271 | assertSame($declarationOfIndependence->getDecadeOrdinal(), 178, __LINE__); 272 | assertSame($declarationOfIndependence->getDecadeNominal(), 1770, __LINE__); 273 | assertSame($declarationOfIndependence->getCenturyOrdinal(), 18, __LINE__); 274 | assertSame($declarationOfIndependence->getCenturyNominal(), 1700, __LINE__); 275 | assertSame($declarationOfIndependence->getMillenniumOrdinal(), 2, __LINE__); 276 | assertSame($declarationOfIndependence->getMillenniumNominal(), 1000, __LINE__); 277 | assertSame($declarationOfIndependence->withYear(111)->getDecadeOrdinal(), 12, __LINE__); 278 | assertSame($declarationOfIndependence->withYear(111)->getDecadeNominal(), 110, __LINE__); 279 | assertSame($declarationOfIndependence->withYear(111)->getCenturyOrdinal(), 2, __LINE__); 280 | assertSame($declarationOfIndependence->withYear(111)->getCenturyNominal(), 100, __LINE__); 281 | assertSame($declarationOfIndependence->withYear(111)->getMillenniumOrdinal(), 1, __LINE__); 282 | assertSame($declarationOfIndependence->withYear(111)->getMillenniumNominal(), 0, __LINE__); 283 | assertSame($declarationOfIndependence->withYear(5)->getDecadeOrdinal(), 1, __LINE__); 284 | assertSame($declarationOfIndependence->withYear(5)->getDecadeNominal(), 0, __LINE__); 285 | assertSame($declarationOfIndependence->withYear(5)->getCenturyOrdinal(), 1, __LINE__); 286 | assertSame($declarationOfIndependence->withYear(5)->getCenturyNominal(), 0, __LINE__); 287 | assertSame($declarationOfIndependence->withYear(5)->getMillenniumOrdinal(), 1, __LINE__); 288 | assertSame($declarationOfIndependence->withYear(5)->getMillenniumNominal(), 0, __LINE__); 289 | assertSame($declarationOfIndependence->withYear(0)->getDecadeOrdinal(), 0, __LINE__); 290 | assertSame($declarationOfIndependence->withYear(0)->getDecadeNominal(), 0, __LINE__); 291 | assertSame($declarationOfIndependence->withYear(0)->getCenturyOrdinal(), 0, __LINE__); 292 | assertSame($declarationOfIndependence->withYear(0)->getCenturyNominal(), 0, __LINE__); 293 | assertSame($declarationOfIndependence->withYear(0)->getMillenniumOrdinal(), 0, __LINE__); 294 | assertSame($declarationOfIndependence->withYear(0)->getMillenniumNominal(), 0, __LINE__); 295 | assertSame($declarationOfIndependence->withYear(-5)->getDecadeOrdinal(), -1, __LINE__); 296 | assertSame($declarationOfIndependence->withYear(-5)->getDecadeNominal(), 0, __LINE__); 297 | assertSame($declarationOfIndependence->withYear(-5)->getCenturyOrdinal(), -1, __LINE__); 298 | assertSame($declarationOfIndependence->withYear(-5)->getCenturyNominal(), 0, __LINE__); 299 | assertSame($declarationOfIndependence->withYear(-5)->getMillenniumOrdinal(), -1, __LINE__); 300 | assertSame($declarationOfIndependence->withYear(-5)->getMillenniumNominal(), 0, __LINE__); 301 | assertSame($declarationOfIndependence->withYear(-111)->getDecadeOrdinal(), -12, __LINE__); 302 | assertSame($declarationOfIndependence->withYear(-111)->getDecadeNominal(), -110, __LINE__); 303 | assertSame($declarationOfIndependence->withYear(-111)->getCenturyOrdinal(), -2, __LINE__); 304 | assertSame($declarationOfIndependence->withYear(-111)->getCenturyNominal(), -100, __LINE__); 305 | assertSame($declarationOfIndependence->withYear(-111)->getMillenniumOrdinal(), -1, __LINE__); 306 | assertSame($declarationOfIndependence->withYear(-111)->getMillenniumNominal(), 0, __LINE__); 307 | assertSame($declarationOfIndependence->withYear(-1776)->getDecadeOrdinal(), -178, __LINE__); 308 | assertSame($declarationOfIndependence->withYear(-1776)->getDecadeNominal(), -1770, __LINE__); 309 | assertSame($declarationOfIndependence->withYear(-1776)->getCenturyOrdinal(), -18, __LINE__); 310 | assertSame($declarationOfIndependence->withYear(-1776)->getCenturyNominal(), -1700, __LINE__); 311 | assertSame($declarationOfIndependence->withYear(-1776)->getMillenniumOrdinal(), -2, __LINE__); 312 | assertSame($declarationOfIndependence->withYear(-1776)->getMillenniumNominal(), -1000, __LINE__); 313 | 314 | assertSame($smallStepForMan->isDst(), true, __LINE__); 315 | assertSame($smallStepForMan->isDaylightSavingTime(), true, __LINE__); 316 | assertSame($smallStepForMan->plusMonths(6)->isDst(), false, __LINE__); 317 | assertSame($smallStepForMan->plusMonths(6)->isDaylightSavingTime(), false, __LINE__); 318 | assertSame($smallStepForMan->withTimeZone('Australia/Melbourne')->isDst(), false, __LINE__); 319 | assertSame($smallStepForMan->withTimeZone('Australia/Melbourne')->isDaylightSavingTime(), false, __LINE__); 320 | assertSame($smallStepForMan->withTimeZone('Europe/Berlin')->isDst(), false, __LINE__); 321 | assertSame($smallStepForMan->withTimeZone('Europe/Berlin')->isDaylightSavingTime(), false, __LINE__); 322 | assertSame($smallStepForMan->withTimeZone('Europe/Berlin')->plusYears(20)->isDst(), true, __LINE__); 323 | assertSame($smallStepForMan->withTimeZone('Europe/Berlin')->plusYears(20)->isDaylightSavingTime(), true, __LINE__); 324 | 325 | assertSame($smallStepForMan->isLeapYear(), false, __LINE__); 326 | assertSame($smallStepForMan->plusYears(1)->isLeapYear(), false, __LINE__); 327 | assertSame($smallStepForMan->plusYears(2)->isLeapYear(), false, __LINE__); 328 | assertSame($smallStepForMan->plusYears(3)->isLeapYear(), true, __LINE__); 329 | assertSame($smallStepForMan->plusYears(4)->isLeapYear(), false, __LINE__); 330 | 331 | assertSame($moonLanding->getYearInDecade(), 9, __LINE__); 332 | assertSame($moonLanding->getYearInCentury(), 69, __LINE__); 333 | assertSame($moonLanding->getYearInMillennium(), 969, __LINE__); 334 | 335 | assertSame($declarationOfIndependence->isSame($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 336 | assertSame($declarationOfIndependence->isSame($declarationOfIndependence), true, __LINE__); 337 | assertSame($declarationOfIndependence->isMinuteSame($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 338 | assertSame($declarationOfIndependence->isMinuteSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 339 | assertSame($declarationOfIndependence->isMinuteSame($declarationOfIndependence), true, __LINE__); 340 | assertSame($declarationOfIndependence->isHourSame($declarationOfIndependence->plusHours(1)), false, __LINE__); 341 | assertSame($declarationOfIndependence->isHourSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 342 | assertSame($declarationOfIndependence->isHourSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 343 | assertSame($declarationOfIndependence->isHourSame($declarationOfIndependence), true, __LINE__); 344 | assertSame($declarationOfIndependence->isDaySame($declarationOfIndependence->plusDays(1)), false, __LINE__); 345 | assertSame($declarationOfIndependence->isDaySame($declarationOfIndependence->plusHours(1)), true, __LINE__); 346 | assertSame($declarationOfIndependence->isDaySame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 347 | assertSame($declarationOfIndependence->isDaySame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 348 | assertSame($declarationOfIndependence->isDaySame($declarationOfIndependence), true, __LINE__); 349 | assertSame($declarationOfIndependence->isMonthSame($declarationOfIndependence->plusMonths(1)), false, __LINE__); 350 | assertSame($declarationOfIndependence->isMonthSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 351 | assertSame($declarationOfIndependence->isMonthSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 352 | assertSame($declarationOfIndependence->isMonthSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 353 | assertSame($declarationOfIndependence->isMonthSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 354 | assertSame($declarationOfIndependence->isMonthSame($declarationOfIndependence), true, __LINE__); 355 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence->plusYears(1)), false, __LINE__); 356 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 357 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 358 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 359 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 360 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 361 | assertSame($declarationOfIndependence->isYearSame($declarationOfIndependence), true, __LINE__); 362 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusYears(10)), false, __LINE__); 363 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusYears(1)), true, __LINE__); 364 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 365 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 366 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 367 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 368 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 369 | assertSame($declarationOfIndependence->isDecadeSame($declarationOfIndependence), true, __LINE__); 370 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusYears(100)), false, __LINE__); 371 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusYears(10)), true, __LINE__); 372 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusYears(1)), true, __LINE__); 373 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 374 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusDays(1)), true, __LINE__); 375 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusHours(1)), true, __LINE__); 376 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 377 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 378 | assertSame($declarationOfIndependence->isCenturySame($declarationOfIndependence), true, __LINE__); 379 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusYears(1000)), false, __LINE__); 380 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusYears(100)), true, __LINE__); 381 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusYears(10)), true, __LINE__); 382 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusYears(1)), true, __LINE__); 383 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 384 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 385 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 386 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 387 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 388 | assertSame($declarationOfIndependence->isMillenniumSame($declarationOfIndependence), true, __LINE__); 389 | 390 | assertSame($declarationOfIndependence->isBefore($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 391 | assertSame($declarationOfIndependence->isBefore($declarationOfIndependence), false, __LINE__); 392 | assertSame($declarationOfIndependence->isMinuteBefore($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 393 | assertSame($declarationOfIndependence->isMinuteBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 394 | assertSame($declarationOfIndependence->isMinuteBefore($declarationOfIndependence), false, __LINE__); 395 | assertSame($declarationOfIndependence->isHourBefore($declarationOfIndependence->plusHours(1)), true, __LINE__); 396 | assertSame($declarationOfIndependence->isHourBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 397 | assertSame($declarationOfIndependence->isHourBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 398 | assertSame($declarationOfIndependence->isHourBefore($declarationOfIndependence), false, __LINE__); 399 | assertSame($declarationOfIndependence->isDayBefore($declarationOfIndependence->plusDays(1)), true, __LINE__); 400 | assertSame($declarationOfIndependence->isDayBefore($declarationOfIndependence->plusHours(1)), false, __LINE__); 401 | assertSame($declarationOfIndependence->isDayBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 402 | assertSame($declarationOfIndependence->isDayBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 403 | assertSame($declarationOfIndependence->isDayBefore($declarationOfIndependence), false, __LINE__); 404 | assertSame($declarationOfIndependence->isMonthBefore($declarationOfIndependence->plusMonths(1)), true, __LINE__); 405 | assertSame($declarationOfIndependence->isMonthBefore($declarationOfIndependence->plusDays(1)), false, __LINE__); 406 | assertSame($declarationOfIndependence->isMonthBefore($declarationOfIndependence->plusHours(1)), false, __LINE__); 407 | assertSame($declarationOfIndependence->isMonthBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 408 | assertSame($declarationOfIndependence->isMonthBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 409 | assertSame($declarationOfIndependence->isMonthBefore($declarationOfIndependence), false, __LINE__); 410 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence->plusYears(1)), true, __LINE__); 411 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence->plusMonths(1)), false, __LINE__); 412 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence->plusDays(1)), false, __LINE__); 413 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence->plusHours(1)), false, __LINE__); 414 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 415 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 416 | assertSame($declarationOfIndependence->isYearBefore($declarationOfIndependence), false, __LINE__); 417 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusYears(10)), true, __LINE__); 418 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusYears(1)), false, __LINE__); 419 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusMonths(1)), false, __LINE__); 420 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusDays(1)), false, __LINE__); 421 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusHours(1)), false, __LINE__); 422 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 423 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 424 | assertSame($declarationOfIndependence->isDecadeBefore($declarationOfIndependence), false, __LINE__); 425 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusYears(100)), true, __LINE__); 426 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusYears(10)), false, __LINE__); 427 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusYears(1)), false, __LINE__); 428 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusMonths(1)), false, __LINE__); 429 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusDays(1)), false, __LINE__); 430 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusHours(1)), false, __LINE__); 431 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 432 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 433 | assertSame($declarationOfIndependence->isCenturyBefore($declarationOfIndependence), false, __LINE__); 434 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusYears(1000)), true, __LINE__); 435 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusYears(100)), false, __LINE__); 436 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusYears(10)), false, __LINE__); 437 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusYears(1)), false, __LINE__); 438 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusMonths(1)), false, __LINE__); 439 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusDays(1)), false, __LINE__); 440 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusHours(1)), false, __LINE__); 441 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 442 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 443 | assertSame($declarationOfIndependence->isMillenniumBefore($declarationOfIndependence), false, __LINE__); 444 | 445 | assertSame($declarationOfIndependence->isAfter($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 446 | assertSame($declarationOfIndependence->isAfter($declarationOfIndependence), false, __LINE__); 447 | assertSame($declarationOfIndependence->isMinuteAfter($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 448 | assertSame($declarationOfIndependence->isMinuteAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 449 | assertSame($declarationOfIndependence->isMinuteAfter($declarationOfIndependence), false, __LINE__); 450 | assertSame($declarationOfIndependence->isHourAfter($declarationOfIndependence->minusHours(1)), true, __LINE__); 451 | assertSame($declarationOfIndependence->isHourAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 452 | assertSame($declarationOfIndependence->isHourAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 453 | assertSame($declarationOfIndependence->isHourAfter($declarationOfIndependence), false, __LINE__); 454 | assertSame($declarationOfIndependence->isDayAfter($declarationOfIndependence->minusDays(1)), true, __LINE__); 455 | assertSame($declarationOfIndependence->isDayAfter($declarationOfIndependence->minusHours(1)), false, __LINE__); 456 | assertSame($declarationOfIndependence->isDayAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 457 | assertSame($declarationOfIndependence->isDayAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 458 | assertSame($declarationOfIndependence->isDayAfter($declarationOfIndependence), false, __LINE__); 459 | assertSame($declarationOfIndependence->isMonthAfter($declarationOfIndependence->minusMonths(1)), true, __LINE__); 460 | assertSame($declarationOfIndependence->isMonthAfter($declarationOfIndependence->minusDays(1)), false, __LINE__); 461 | assertSame($declarationOfIndependence->isMonthAfter($declarationOfIndependence->minusHours(1)), false, __LINE__); 462 | assertSame($declarationOfIndependence->isMonthAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 463 | assertSame($declarationOfIndependence->isMonthAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 464 | assertSame($declarationOfIndependence->isMonthAfter($declarationOfIndependence), false, __LINE__); 465 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence->minusYears(1)), true, __LINE__); 466 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence->minusMonths(1)), false, __LINE__); 467 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence->minusDays(1)), false, __LINE__); 468 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence->minusHours(1)), false, __LINE__); 469 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 470 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 471 | assertSame($declarationOfIndependence->isYearAfter($declarationOfIndependence), false, __LINE__); 472 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusYears(10)), true, __LINE__); 473 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusYears(1)), false, __LINE__); 474 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusMonths(1)), false, __LINE__); 475 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusDays(1)), false, __LINE__); 476 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusHours(1)), false, __LINE__); 477 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 478 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 479 | assertSame($declarationOfIndependence->isDecadeAfter($declarationOfIndependence), false, __LINE__); 480 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusYears(100)), true, __LINE__); 481 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusYears(10)), false, __LINE__); 482 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusYears(1)), false, __LINE__); 483 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusMonths(1)), false, __LINE__); 484 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusDays(1)), false, __LINE__); 485 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusHours(1)), false, __LINE__); 486 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 487 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 488 | assertSame($declarationOfIndependence->isCenturyAfter($declarationOfIndependence), false, __LINE__); 489 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusYears(1000)), true, __LINE__); 490 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusYears(100)), false, __LINE__); 491 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusYears(10)), false, __LINE__); 492 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusYears(1)), false, __LINE__); 493 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusMonths(1)), false, __LINE__); 494 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusDays(1)), false, __LINE__); 495 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusHours(1)), false, __LINE__); 496 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 497 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 498 | assertSame($declarationOfIndependence->isMillenniumAfter($declarationOfIndependence), false, __LINE__); 499 | 500 | assertSame($declarationOfIndependence->isBeforeOrSame($declarationOfIndependence->minusSeconds(1)), false, __LINE__); 501 | assertSame($declarationOfIndependence->isBeforeOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 502 | assertSame($declarationOfIndependence->isBeforeOrSame($declarationOfIndependence), true, __LINE__); 503 | assertSame($declarationOfIndependence->isMinuteBeforeOrSame($declarationOfIndependence->minusMinutes(1)), false, __LINE__); 504 | assertSame($declarationOfIndependence->isMinuteBeforeOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 505 | assertSame($declarationOfIndependence->isMinuteBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 506 | assertSame($declarationOfIndependence->isMinuteBeforeOrSame($declarationOfIndependence), true, __LINE__); 507 | assertSame($declarationOfIndependence->isHourBeforeOrSame($declarationOfIndependence->minusHours(1)), false, __LINE__); 508 | assertSame($declarationOfIndependence->isHourBeforeOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 509 | assertSame($declarationOfIndependence->isHourBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 510 | assertSame($declarationOfIndependence->isHourBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 511 | assertSame($declarationOfIndependence->isHourBeforeOrSame($declarationOfIndependence), true, __LINE__); 512 | assertSame($declarationOfIndependence->isDayBeforeOrSame($declarationOfIndependence->minusDays(1)), false, __LINE__); 513 | assertSame($declarationOfIndependence->isDayBeforeOrSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 514 | assertSame($declarationOfIndependence->isDayBeforeOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 515 | assertSame($declarationOfIndependence->isDayBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 516 | assertSame($declarationOfIndependence->isDayBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 517 | assertSame($declarationOfIndependence->isDayBeforeOrSame($declarationOfIndependence), true, __LINE__); 518 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence->minusMonths(1)), false, __LINE__); 519 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 520 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence->minusDays(1)), true, __LINE__); 521 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 522 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 523 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 524 | assertSame($declarationOfIndependence->isMonthBeforeOrSame($declarationOfIndependence), true, __LINE__); 525 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->minusYears(1)), false, __LINE__); 526 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->plusYears(1)), true, __LINE__); 527 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->minusMonths(1)), true, __LINE__); 528 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->minusDays(1)), true, __LINE__); 529 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 530 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 531 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 532 | assertSame($declarationOfIndependence->isYearBeforeOrSame($declarationOfIndependence), true, __LINE__); 533 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusYears(10)), false, __LINE__); 534 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->plusYears(10)), true, __LINE__); 535 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusYears(1)), true, __LINE__); 536 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusMonths(1)), true, __LINE__); 537 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusDays(1)), true, __LINE__); 538 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 539 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 540 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 541 | assertSame($declarationOfIndependence->isDecadeBeforeOrSame($declarationOfIndependence), true, __LINE__); 542 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusYears(100)), false, __LINE__); 543 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->plusYears(100)), true, __LINE__); 544 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusYears(10)), true, __LINE__); 545 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusYears(1)), true, __LINE__); 546 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusMonths(1)), true, __LINE__); 547 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusDays(1)), true, __LINE__); 548 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 549 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 550 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 551 | assertSame($declarationOfIndependence->isCenturyBeforeOrSame($declarationOfIndependence), true, __LINE__); 552 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusYears(1000)), false, __LINE__); 553 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->plusYears(1000)), true, __LINE__); 554 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusYears(100)), true, __LINE__); 555 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusYears(10)), true, __LINE__); 556 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusYears(1)), true, __LINE__); 557 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusMonths(1)), true, __LINE__); 558 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusDays(1)), true, __LINE__); 559 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 560 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 561 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 562 | assertSame($declarationOfIndependence->isMillenniumBeforeOrSame($declarationOfIndependence), true, __LINE__); 563 | 564 | assertSame($declarationOfIndependence->isAfterOrSame($declarationOfIndependence->plusSeconds(1)), false, __LINE__); 565 | assertSame($declarationOfIndependence->isAfterOrSame($declarationOfIndependence->minusSeconds(1)), true, __LINE__); 566 | assertSame($declarationOfIndependence->isAfterOrSame($declarationOfIndependence), true, __LINE__); 567 | assertSame($declarationOfIndependence->isMinuteAfterOrSame($declarationOfIndependence->plusMinutes(1)), false, __LINE__); 568 | assertSame($declarationOfIndependence->isMinuteAfterOrSame($declarationOfIndependence->minusMinutes(1)), true, __LINE__); 569 | assertSame($declarationOfIndependence->isMinuteAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 570 | assertSame($declarationOfIndependence->isMinuteAfterOrSame($declarationOfIndependence), true, __LINE__); 571 | assertSame($declarationOfIndependence->isHourAfterOrSame($declarationOfIndependence->plusHours(1)), false, __LINE__); 572 | assertSame($declarationOfIndependence->isHourAfterOrSame($declarationOfIndependence->minusHours(1)), true, __LINE__); 573 | assertSame($declarationOfIndependence->isHourAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 574 | assertSame($declarationOfIndependence->isHourAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 575 | assertSame($declarationOfIndependence->isHourAfterOrSame($declarationOfIndependence), true, __LINE__); 576 | assertSame($declarationOfIndependence->isDayAfterOrSame($declarationOfIndependence->plusDays(1)), false, __LINE__); 577 | assertSame($declarationOfIndependence->isDayAfterOrSame($declarationOfIndependence->minusDays(1)), true, __LINE__); 578 | assertSame($declarationOfIndependence->isDayAfterOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 579 | assertSame($declarationOfIndependence->isDayAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 580 | assertSame($declarationOfIndependence->isDayAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 581 | assertSame($declarationOfIndependence->isDayAfterOrSame($declarationOfIndependence), true, __LINE__); 582 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence->plusMonths(1)), false, __LINE__); 583 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence->minusMonths(1)), true, __LINE__); 584 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 585 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 586 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 587 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 588 | assertSame($declarationOfIndependence->isMonthAfterOrSame($declarationOfIndependence), true, __LINE__); 589 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->plusYears(1)), false, __LINE__); 590 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->minusYears(1)), true, __LINE__); 591 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 592 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 593 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 594 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 595 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 596 | assertSame($declarationOfIndependence->isYearAfterOrSame($declarationOfIndependence), true, __LINE__); 597 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusYears(10)), false, __LINE__); 598 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->minusYears(10)), true, __LINE__); 599 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusYears(1)), true, __LINE__); 600 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 601 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 602 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 603 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 604 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 605 | assertSame($declarationOfIndependence->isDecadeAfterOrSame($declarationOfIndependence), true, __LINE__); 606 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusYears(100)), false, __LINE__); 607 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->minusYears(100)), true, __LINE__); 608 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusYears(10)), true, __LINE__); 609 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusYears(1)), true, __LINE__); 610 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 611 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 612 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 613 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 614 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 615 | assertSame($declarationOfIndependence->isCenturyAfterOrSame($declarationOfIndependence), true, __LINE__); 616 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusYears(1000)), false, __LINE__); 617 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->minusYears(1000)), true, __LINE__); 618 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusYears(100)), true, __LINE__); 619 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusYears(10)), true, __LINE__); 620 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusYears(1)), true, __LINE__); 621 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusMonths(1)), true, __LINE__); 622 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusDays(1)), true, __LINE__); 623 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusHours(1)), true, __LINE__); 624 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusMinutes(1)), true, __LINE__); 625 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence->plusSeconds(1)), true, __LINE__); 626 | assertSame($declarationOfIndependence->isMillenniumAfterOrSame($declarationOfIndependence), true, __LINE__); 627 | 628 | assertSame($now->minusSeconds(1)->isPast(), true, __LINE__); 629 | assertSame($now->isPast(), false, __LINE__); 630 | assertSame($now->minusMinutes(1)->isPastMinute(), true, __LINE__); 631 | assertSame($now->minusSeconds(1)->isPastMinute(), false, __LINE__); 632 | assertSame($now->isPastMinute(), false, __LINE__); 633 | assertSame($now->minusHours(1)->isPastHour(), true, __LINE__); 634 | assertSame($now->minusMinutes(1)->isPastHour(), false, __LINE__); 635 | assertSame($now->minusSeconds(1)->isPastHour(), false, __LINE__); 636 | assertSame($now->isPastHour(), false, __LINE__); 637 | assertSame($now->minusDays(1)->isPastDay(), true, __LINE__); 638 | assertSame($now->minusHours(1)->isPastDay(), false, __LINE__); 639 | assertSame($now->minusMinutes(1)->isPastDay(), false, __LINE__); 640 | assertSame($now->minusSeconds(1)->isPastDay(), false, __LINE__); 641 | assertSame($now->isPastDay(), false, __LINE__); 642 | assertSame($now->minusMonths(1)->isPastMonth(), true, __LINE__); 643 | assertSame($now->minusDays(1)->isPastMonth(), false, __LINE__); 644 | assertSame($now->minusHours(1)->isPastMonth(), false, __LINE__); 645 | assertSame($now->minusMinutes(1)->isPastMonth(), false, __LINE__); 646 | assertSame($now->minusSeconds(1)->isPastMonth(), false, __LINE__); 647 | assertSame($now->isPastMonth(), false, __LINE__); 648 | assertSame($now->minusYears(1)->isPastYear(), true, __LINE__); 649 | assertSame($now->minusMonths(1)->isPastYear(), false, __LINE__); 650 | assertSame($now->minusDays(1)->isPastYear(), false, __LINE__); 651 | assertSame($now->minusHours(1)->isPastYear(), false, __LINE__); 652 | assertSame($now->minusMinutes(1)->isPastYear(), false, __LINE__); 653 | assertSame($now->minusSeconds(1)->isPastYear(), false, __LINE__); 654 | assertSame($now->isPastYear(), false, __LINE__); 655 | assertSame($now->minusYears(10)->isPastDecade(), true, __LINE__); 656 | assertSame($now->minusYears(1)->isPastDecade(), false, __LINE__); 657 | assertSame($now->minusMonths(1)->isPastDecade(), false, __LINE__); 658 | assertSame($now->minusDays(1)->isPastDecade(), false, __LINE__); 659 | assertSame($now->minusHours(1)->isPastDecade(), false, __LINE__); 660 | assertSame($now->minusMinutes(1)->isPastDecade(), false, __LINE__); 661 | assertSame($now->minusSeconds(1)->isPastDecade(), false, __LINE__); 662 | assertSame($now->isPastDecade(), false, __LINE__); 663 | assertSame($now->minusYears(100)->isPastCentury(), true, __LINE__); 664 | assertSame($now->minusYears(10)->isPastCentury(), false, __LINE__); 665 | assertSame($now->minusYears(1)->isPastCentury(), false, __LINE__); 666 | assertSame($now->minusMonths(1)->isPastCentury(), false, __LINE__); 667 | assertSame($now->minusDays(1)->isPastCentury(), false, __LINE__); 668 | assertSame($now->minusHours(1)->isPastCentury(), false, __LINE__); 669 | assertSame($now->minusMinutes(1)->isPastCentury(), false, __LINE__); 670 | assertSame($now->minusSeconds(1)->isPastCentury(), false, __LINE__); 671 | assertSame($now->isPastCentury(), false, __LINE__); 672 | assertSame($now->minusYears(1000)->isPastMillennium(), true, __LINE__); 673 | assertSame($now->minusYears(100)->isPastMillennium(), false, __LINE__); 674 | assertSame($now->minusYears(10)->isPastMillennium(), false, __LINE__); 675 | assertSame($now->minusYears(1)->isPastMillennium(), false, __LINE__); 676 | assertSame($now->minusMonths(1)->isPastMillennium(), false, __LINE__); 677 | assertSame($now->minusDays(1)->isPastMillennium(), false, __LINE__); 678 | assertSame($now->minusHours(1)->isPastMillennium(), false, __LINE__); 679 | assertSame($now->minusMinutes(1)->isPastMillennium(), false, __LINE__); 680 | assertSame($now->minusSeconds(1)->isPastMillennium(), false, __LINE__); 681 | assertSame($now->isPastMillennium(), false, __LINE__); 682 | 683 | assertSame($now->plusSeconds(1)->isFuture(), true, __LINE__); 684 | assertSame($now->isFuture(), false, __LINE__); 685 | assertSame($now->plusMinutes(1)->isFutureMinute(), true, __LINE__); 686 | assertSame($now->plusSeconds(1)->isFutureMinute(), false, __LINE__); 687 | assertSame($now->isFutureMinute(), false, __LINE__); 688 | assertSame($now->plusHours(1)->isFutureHour(), true, __LINE__); 689 | assertSame($now->plusMinutes(1)->isFutureHour(), false, __LINE__); 690 | assertSame($now->plusSeconds(1)->isFutureHour(), false, __LINE__); 691 | assertSame($now->isFutureHour(), false, __LINE__); 692 | assertSame($now->plusDays(1)->isFutureDay(), true, __LINE__); 693 | assertSame($now->plusHours(1)->isFutureDay(), false, __LINE__); 694 | assertSame($now->plusMinutes(1)->isFutureDay(), false, __LINE__); 695 | assertSame($now->plusSeconds(1)->isFutureDay(), false, __LINE__); 696 | assertSame($now->isFutureDay(), false, __LINE__); 697 | assertSame($now->plusMonths(1)->isFutureMonth(), true, __LINE__); 698 | assertSame($now->plusDays(1)->isFutureMonth(), false, __LINE__); 699 | assertSame($now->plusHours(1)->isFutureMonth(), false, __LINE__); 700 | assertSame($now->plusMinutes(1)->isFutureMonth(), false, __LINE__); 701 | assertSame($now->plusSeconds(1)->isFutureMonth(), false, __LINE__); 702 | assertSame($now->isFutureMonth(), false, __LINE__); 703 | assertSame($now->plusYears(1)->isFutureYear(), true, __LINE__); 704 | assertSame($now->plusMonths(1)->isFutureYear(), false, __LINE__); 705 | assertSame($now->plusDays(1)->isFutureYear(), false, __LINE__); 706 | assertSame($now->plusHours(1)->isFutureYear(), false, __LINE__); 707 | assertSame($now->plusMinutes(1)->isFutureYear(), false, __LINE__); 708 | assertSame($now->plusSeconds(1)->isFutureYear(), false, __LINE__); 709 | assertSame($now->isFutureYear(), false, __LINE__); 710 | assertSame($now->plusYears(10)->isFutureDecade(), true, __LINE__); 711 | assertSame($now->plusYears(1)->isFutureDecade(), false, __LINE__); 712 | assertSame($now->plusMonths(1)->isFutureDecade(), false, __LINE__); 713 | assertSame($now->plusDays(1)->isFutureDecade(), false, __LINE__); 714 | assertSame($now->plusHours(1)->isFutureDecade(), false, __LINE__); 715 | assertSame($now->plusMinutes(1)->isFutureDecade(), false, __LINE__); 716 | assertSame($now->plusSeconds(1)->isFutureDecade(), false, __LINE__); 717 | assertSame($now->isFutureDecade(), false, __LINE__); 718 | assertSame($now->plusYears(100)->isFutureCentury(), true, __LINE__); 719 | assertSame($now->plusYears(10)->isFutureCentury(), false, __LINE__); 720 | assertSame($now->plusYears(1)->isFutureCentury(), false, __LINE__); 721 | assertSame($now->plusMonths(1)->isFutureCentury(), false, __LINE__); 722 | assertSame($now->plusDays(1)->isFutureCentury(), false, __LINE__); 723 | assertSame($now->plusHours(1)->isFutureCentury(), false, __LINE__); 724 | assertSame($now->plusMinutes(1)->isFutureCentury(), false, __LINE__); 725 | assertSame($now->plusSeconds(1)->isFutureCentury(), false, __LINE__); 726 | assertSame($now->isFutureCentury(), false, __LINE__); 727 | assertSame($now->plusYears(1000)->isFutureMillennium(), true, __LINE__); 728 | assertSame($now->plusYears(100)->isFutureMillennium(), false, __LINE__); 729 | assertSame($now->plusYears(10)->isFutureMillennium(), false, __LINE__); 730 | assertSame($now->plusYears(1)->isFutureMillennium(), false, __LINE__); 731 | assertSame($now->plusMonths(1)->isFutureMillennium(), false, __LINE__); 732 | assertSame($now->plusDays(1)->isFutureMillennium(), false, __LINE__); 733 | assertSame($now->plusHours(1)->isFutureMillennium(), false, __LINE__); 734 | assertSame($now->plusMinutes(1)->isFutureMillennium(), false, __LINE__); 735 | assertSame($now->plusSeconds(1)->isFutureMillennium(), false, __LINE__); 736 | assertSame($now->isFutureMillennium(), false, __LINE__); 737 | 738 | assertSame($now->minusHours(28)->isToday(), false, __LINE__); 739 | assertSame($now->minusHours(4)->isToday(), true, __LINE__); 740 | assertSame($now->isToday(), true, __LINE__); 741 | assertSame($now->plusHours(4)->isToday(), true, __LINE__); 742 | assertSame($now->plusHours(28)->isToday(), false, __LINE__); 743 | 744 | assertSame($now->minusHours(28)->isYesterday(), true, __LINE__); 745 | assertSame($now->minusHours(4)->isYesterday(), false, __LINE__); 746 | assertSame($now->isYesterday(), false, __LINE__); 747 | assertSame($now->plusHours(4)->isYesterday(), false, __LINE__); 748 | assertSame($now->plusHours(28)->isYesterday(), false, __LINE__); 749 | 750 | assertSame($now->minusHours(28)->isTomorrow(), false, __LINE__); 751 | assertSame($now->minusHours(4)->isTomorrow(), false, __LINE__); 752 | assertSame($now->isTomorrow(), false, __LINE__); 753 | assertSame($now->plusHours(4)->isTomorrow(), false, __LINE__); 754 | assertSame($now->plusHours(28)->isTomorrow(), true, __LINE__); 755 | 756 | assertSame($now->plusYears(7)->minusHours(28)->isAnniversary(), false, __LINE__); 757 | assertSame($now->plusYears(7)->minusHours(4)->isAnniversary(), true, __LINE__); 758 | assertSame($now->minusHours(28)->isAnniversary(), false, __LINE__); 759 | assertSame($now->minusHours(4)->isAnniversary(), true, __LINE__); 760 | assertSame($now->plusYears(7)->isAnniversary(), true, __LINE__); 761 | assertSame($now->isAnniversary(), true, __LINE__); 762 | assertSame($now->minusYears(7)->isAnniversary(), true, __LINE__); 763 | assertSame($now->plusHours(4)->isAnniversary(), true, __LINE__); 764 | assertSame($now->plusHours(28)->isAnniversary(), false, __LINE__); 765 | assertSame($now->minusYears(7)->plusHours(4)->isAnniversary(), true, __LINE__); 766 | assertSame($now->minusYears(7)->plusHours(28)->isAnniversary(), false, __LINE__); 767 | 768 | assertSame($now->minusDays(6)->isLastWeek(), true, __LINE__); 769 | assertSame($now->minusDays(5)->isLastWeek(), true, __LINE__); 770 | assertSame($now->minusDays(4)->isLastWeek(), false, __LINE__); 771 | assertSame($now->minusDays(3)->isLastWeek(), false, __LINE__); 772 | assertSame($now->plusDays(1)->isLastWeek(), false, __LINE__); 773 | assertSame($now->plusDays(2)->isLastWeek(), false, __LINE__); 774 | assertSame($now->plusDays(3)->isLastWeek(), false, __LINE__); 775 | assertSame($now->plusDays(4)->isLastWeek(), false, __LINE__); 776 | assertSame($now->minusDays(6)->isThisWeek(), false, __LINE__); 777 | assertSame($now->minusDays(5)->isThisWeek(), false, __LINE__); 778 | assertSame($now->minusDays(4)->isThisWeek(), true, __LINE__); 779 | assertSame($now->minusDays(3)->isThisWeek(), true, __LINE__); 780 | assertSame($now->plusDays(1)->isThisWeek(), true, __LINE__); 781 | assertSame($now->plusDays(2)->isThisWeek(), true, __LINE__); 782 | assertSame($now->plusDays(3)->isThisWeek(), false, __LINE__); 783 | assertSame($now->plusDays(4)->isThisWeek(), false, __LINE__); 784 | assertSame($now->minusDays(6)->isNextWeek(), false, __LINE__); 785 | assertSame($now->minusDays(5)->isNextWeek(), false, __LINE__); 786 | assertSame($now->minusDays(4)->isNextWeek(), false, __LINE__); 787 | assertSame($now->minusDays(3)->isNextWeek(), false, __LINE__); 788 | assertSame($now->plusDays(1)->isNextWeek(), false, __LINE__); 789 | assertSame($now->plusDays(2)->isNextWeek(), false, __LINE__); 790 | assertSame($now->plusDays(3)->isNextWeek(), true, __LINE__); 791 | assertSame($now->plusDays(4)->isNextWeek(), true, __LINE__); 792 | 793 | assertSame($now->minusDays(16)->isLastMonth(), true, __LINE__); 794 | assertSame($now->minusDays(15)->isLastMonth(), true, __LINE__); 795 | assertSame($now->minusDays(14)->isLastMonth(), false, __LINE__); 796 | assertSame($now->minusDays(13)->isLastMonth(), false, __LINE__); 797 | assertSame($now->plusDays(14)->isLastMonth(), false, __LINE__); 798 | assertSame($now->plusDays(15)->isLastMonth(), false, __LINE__); 799 | assertSame($now->plusDays(16)->isLastMonth(), false, __LINE__); 800 | assertSame($now->plusDays(17)->isLastMonth(), false, __LINE__); 801 | assertSame($now->minusDays(16)->isThisMonth(), false, __LINE__); 802 | assertSame($now->minusDays(15)->isThisMonth(), false, __LINE__); 803 | assertSame($now->minusDays(14)->isThisMonth(), true, __LINE__); 804 | assertSame($now->minusDays(13)->isThisMonth(), true, __LINE__); 805 | assertSame($now->plusDays(14)->isThisMonth(), true, __LINE__); 806 | assertSame($now->plusDays(15)->isThisMonth(), true, __LINE__); 807 | assertSame($now->plusDays(16)->isThisMonth(), false, __LINE__); 808 | assertSame($now->plusDays(17)->isThisMonth(), false, __LINE__); 809 | assertSame($now->minusDays(16)->isNextMonth(), false, __LINE__); 810 | assertSame($now->minusDays(15)->isNextMonth(), false, __LINE__); 811 | assertSame($now->minusDays(14)->isNextMonth(), false, __LINE__); 812 | assertSame($now->minusDays(13)->isNextMonth(), false, __LINE__); 813 | assertSame($now->plusDays(14)->isNextMonth(), false, __LINE__); 814 | assertSame($now->plusDays(15)->isNextMonth(), false, __LINE__); 815 | assertSame($now->plusDays(16)->isNextMonth(), true, __LINE__); 816 | assertSame($now->plusDays(17)->isNextMonth(), true, __LINE__); 817 | 818 | assertSame($now->minusMonths(7)->isLastYear(), true, __LINE__); 819 | assertSame($now->minusMonths(6)->isLastYear(), true, __LINE__); 820 | assertSame($now->minusMonths(5)->isLastYear(), false, __LINE__); 821 | assertSame($now->minusMonths(4)->isLastYear(), false, __LINE__); 822 | assertSame($now->plusMonths(5)->isLastYear(), false, __LINE__); 823 | assertSame($now->plusMonths(6)->isLastYear(), false, __LINE__); 824 | assertSame($now->plusMonths(7)->isLastYear(), false, __LINE__); 825 | assertSame($now->plusMonths(8)->isLastYear(), false, __LINE__); 826 | assertSame($now->minusMonths(7)->isThisYear(), false, __LINE__); 827 | assertSame($now->minusMonths(6)->isThisYear(), false, __LINE__); 828 | assertSame($now->minusMonths(5)->isThisYear(), true, __LINE__); 829 | assertSame($now->minusMonths(4)->isThisYear(), true, __LINE__); 830 | assertSame($now->plusMonths(5)->isThisYear(), true, __LINE__); 831 | assertSame($now->plusMonths(6)->isThisYear(), true, __LINE__); 832 | assertSame($now->plusMonths(7)->isThisYear(), false, __LINE__); 833 | assertSame($now->plusMonths(8)->isThisYear(), false, __LINE__); 834 | assertSame($now->minusMonths(7)->isNextYear(), false, __LINE__); 835 | assertSame($now->minusMonths(6)->isNextYear(), false, __LINE__); 836 | assertSame($now->minusMonths(5)->isNextYear(), false, __LINE__); 837 | assertSame($now->minusMonths(4)->isNextYear(), false, __LINE__); 838 | assertSame($now->plusMonths(5)->isNextYear(), false, __LINE__); 839 | assertSame($now->plusMonths(6)->isNextYear(), false, __LINE__); 840 | assertSame($now->plusMonths(7)->isNextYear(), true, __LINE__); 841 | assertSame($now->plusMonths(8)->isNextYear(), true, __LINE__); 842 | 843 | assertSame($now->minusYears(7)->isLastDecade(), true, __LINE__); 844 | assertSame($now->minusYears(6)->isLastDecade(), true, __LINE__); 845 | assertSame($now->minusYears(5)->isLastDecade(), false, __LINE__); 846 | assertSame($now->minusYears(4)->isLastDecade(), false, __LINE__); 847 | assertSame($now->plusYears(3)->isLastDecade(), false, __LINE__); 848 | assertSame($now->plusYears(4)->isLastDecade(), false, __LINE__); 849 | assertSame($now->plusYears(5)->isLastDecade(), false, __LINE__); 850 | assertSame($now->plusYears(6)->isLastDecade(), false, __LINE__); 851 | assertSame($now->minusYears(7)->isThisDecade(), false, __LINE__); 852 | assertSame($now->minusYears(6)->isThisDecade(), false, __LINE__); 853 | assertSame($now->minusYears(5)->isThisDecade(), true, __LINE__); 854 | assertSame($now->minusYears(4)->isThisDecade(), true, __LINE__); 855 | assertSame($now->plusYears(3)->isThisDecade(), true, __LINE__); 856 | assertSame($now->plusYears(4)->isThisDecade(), true, __LINE__); 857 | assertSame($now->plusYears(5)->isThisDecade(), false, __LINE__); 858 | assertSame($now->plusYears(6)->isThisDecade(), false, __LINE__); 859 | assertSame($now->minusYears(7)->isNextDecade(), false, __LINE__); 860 | assertSame($now->minusYears(6)->isNextDecade(), false, __LINE__); 861 | assertSame($now->minusYears(5)->isNextDecade(), false, __LINE__); 862 | assertSame($now->minusYears(4)->isNextDecade(), false, __LINE__); 863 | assertSame($now->plusYears(3)->isNextDecade(), false, __LINE__); 864 | assertSame($now->plusYears(4)->isNextDecade(), false, __LINE__); 865 | assertSame($now->plusYears(5)->isNextDecade(), true, __LINE__); 866 | assertSame($now->plusYears(6)->isNextDecade(), true, __LINE__); 867 | 868 | assertSame($now->minusYears(70)->isLastCentury(), true, __LINE__); 869 | assertSame($now->minusYears(60)->isLastCentury(), true, __LINE__); 870 | assertSame($now->minusYears(50)->isLastCentury(), false, __LINE__); 871 | assertSame($now->minusYears(40)->isLastCentury(), false, __LINE__); 872 | assertSame($now->plusYears(30)->isLastCentury(), false, __LINE__); 873 | assertSame($now->plusYears(40)->isLastCentury(), false, __LINE__); 874 | assertSame($now->plusYears(50)->isLastCentury(), false, __LINE__); 875 | assertSame($now->plusYears(60)->isLastCentury(), false, __LINE__); 876 | assertSame($now->minusYears(70)->isThisCentury(), false, __LINE__); 877 | assertSame($now->minusYears(60)->isThisCentury(), false, __LINE__); 878 | assertSame($now->minusYears(50)->isThisCentury(), true, __LINE__); 879 | assertSame($now->minusYears(40)->isThisCentury(), true, __LINE__); 880 | assertSame($now->plusYears(30)->isThisCentury(), true, __LINE__); 881 | assertSame($now->plusYears(40)->isThisCentury(), true, __LINE__); 882 | assertSame($now->plusYears(50)->isThisCentury(), false, __LINE__); 883 | assertSame($now->plusYears(60)->isThisCentury(), false, __LINE__); 884 | assertSame($now->minusYears(70)->isNextCentury(), false, __LINE__); 885 | assertSame($now->minusYears(60)->isNextCentury(), false, __LINE__); 886 | assertSame($now->minusYears(50)->isNextCentury(), false, __LINE__); 887 | assertSame($now->minusYears(40)->isNextCentury(), false, __LINE__); 888 | assertSame($now->plusYears(30)->isNextCentury(), false, __LINE__); 889 | assertSame($now->plusYears(40)->isNextCentury(), false, __LINE__); 890 | assertSame($now->plusYears(50)->isNextCentury(), true, __LINE__); 891 | assertSame($now->plusYears(60)->isNextCentury(), true, __LINE__); 892 | 893 | assertSame($now->minusYears(1000)->isLastMillennium(), true, __LINE__); 894 | assertSame($now->minusYears(900)->isLastMillennium(), true, __LINE__); 895 | assertSame($now->minusYears(800)->isLastMillennium(), false, __LINE__); 896 | assertSame($now->minusYears(700)->isLastMillennium(), false, __LINE__); 897 | assertSame($now->plusYears(50)->isLastMillennium(), false, __LINE__); 898 | assertSame($now->plusYears(100)->isLastMillennium(), false, __LINE__); 899 | assertSame($now->plusYears(150)->isLastMillennium(), false, __LINE__); 900 | assertSame($now->plusYears(200)->isLastMillennium(), false, __LINE__); 901 | assertSame($now->minusYears(1000)->isThisMillennium(), false, __LINE__); 902 | assertSame($now->minusYears(900)->isThisMillennium(), false, __LINE__); 903 | assertSame($now->minusYears(800)->isThisMillennium(), true, __LINE__); 904 | assertSame($now->minusYears(700)->isThisMillennium(), true, __LINE__); 905 | assertSame($now->plusYears(50)->isThisMillennium(), true, __LINE__); 906 | assertSame($now->plusYears(100)->isThisMillennium(), true, __LINE__); 907 | assertSame($now->plusYears(150)->isThisMillennium(), false, __LINE__); 908 | assertSame($now->plusYears(200)->isThisMillennium(), false, __LINE__); 909 | assertSame($now->minusYears(1000)->isNextMillennium(), false, __LINE__); 910 | assertSame($now->minusYears(900)->isNextMillennium(), false, __LINE__); 911 | assertSame($now->minusYears(800)->isNextMillennium(), false, __LINE__); 912 | assertSame($now->minusYears(700)->isNextMillennium(), false, __LINE__); 913 | assertSame($now->plusYears(50)->isNextMillennium(), false, __LINE__); 914 | assertSame($now->plusYears(100)->isNextMillennium(), false, __LINE__); 915 | assertSame($now->plusYears(150)->isNextMillennium(), true, __LINE__); 916 | assertSame($now->plusYears(200)->isNextMillennium(), true, __LINE__); 917 | 918 | assertSame((string) $now->startOfMinute(), '1855-06-15T12:30:00-08:00', __LINE__); 919 | assertSame((string) $now->endOfMinute(), '1855-06-15T12:30:59-08:00', __LINE__); 920 | assertSame((string) $now->startOfHour(), '1855-06-15T12:00:00-08:00', __LINE__); 921 | assertSame((string) $now->endOfHour(), '1855-06-15T12:59:59-08:00', __LINE__); 922 | assertSame((string) $now->startOfDay(), '1855-06-15T00:00:00-08:00', __LINE__); 923 | assertSame((string) $now->endOfDay(), '1855-06-15T23:59:59-08:00', __LINE__); 924 | assertSame((string) $now->startOfWeek(), '1855-06-11T00:00:00-08:00', __LINE__); 925 | assertSame((string) $now->endOfWeek(), '1855-06-17T23:59:59-08:00', __LINE__); 926 | assertSame((string) $now->startOfMonth(), '1855-06-01T00:00:00-08:00', __LINE__); 927 | assertSame((string) $now->endOfMonth(), '1855-06-30T23:59:59-08:00', __LINE__); 928 | assertSame((string) $now->startOfYear(), '1855-01-01T00:00:00-08:00', __LINE__); 929 | assertSame((string) $now->endOfYear(), '1855-12-31T23:59:59-08:00', __LINE__); 930 | assertSame((string) $now->startOfDecade(), '1850-01-01T00:00:00-08:00', __LINE__); 931 | assertSame((string) $now->endOfDecade(), '1859-12-31T23:59:59-08:00', __LINE__); 932 | assertSame((string) $now->startOfCentury(), '1800-01-01T00:00:00-08:00', __LINE__); 933 | assertSame((string) $now->endOfCentury(), '1899-12-31T23:59:59-08:00', __LINE__); 934 | assertSame((string) $now->startOfMillennium(), '1000-01-01T00:00:00-08:00', __LINE__); 935 | assertSame((string) $now->endOfMillennium(), '1999-12-31T23:59:59-08:00', __LINE__); 936 | 937 | assertSame(\round($moonLanding->calculateMillisUntil($smallStepForMan), 4), \round(23891000, 4), __LINE__); 938 | assertSame(\round($moonLanding->calculateSecondsUntil($smallStepForMan), 4), \round(23891, 4), __LINE__); 939 | assertSame(\round($moonLanding->calculateMinutesUntil($smallStepForMan), 4), \round(398.183333333, 4), __LINE__); 940 | assertSame((string) $moonLanding->calculateIso8601DurationUntil($smallStepForMan), 'PT6H38M11S', __LINE__); 941 | 942 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getYears(), 3, __LINE__); 943 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getMonths(), 6, __LINE__); 944 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getWeeks(), 0, __LINE__); 945 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getDays(), 4, __LINE__); 946 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getHours(), 12, __LINE__); 947 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getMinutes(), 30, __LINE__); 948 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getSeconds(), 5, __LINE__); 949 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->isPositive(), false, __LINE__); 950 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->isNegative(), true, __LINE__); 951 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->getSign(), -1, __LINE__); 952 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toIso8601(), '-P3Y6M4DT12H30M5S', __LINE__); 953 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageYears(), 5), -3.51238, __LINE__); 954 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageMonths(), 5), -42.14853, __LINE__); 955 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageWeeks(), 5), -183.26709, __LINE__); 956 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageDays(), 5), -1282.86964, __LINE__); 957 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageHours(), 5), -30788.87139, __LINE__); 958 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageMinutes(), 5), -1847332.28333, __LINE__); 959 | assertSame(\round(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->toAverageSeconds(), 5), -110839937.0, __LINE__); 960 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->plus(\Delight\Temporal\Duration::fromDateTime(0, 22, 0, 0, 0, 96))->toIso8601(), '-P3Y28M4DT12H30M101S', __LINE__); 961 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->multipliedBy(3)->toIso8601(), '-P9Y18M12DT36H90M15S', __LINE__); 962 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->multipliedBy(0)->toIso8601(), 'PT0S', __LINE__); 963 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->multipliedBy(12)->toIso8601(), '-P36Y72M48DT144H360M60S', __LINE__); 964 | assertSame(\Delight\Temporal\Duration::fromIso8601('-P3Y6M4DT12H30M5S')->invert()->toIso8601(), 'P3Y6M4DT12H30M5S', __LINE__); 965 | assertSame(\Delight\Temporal\Duration::fromIso8601('P42W')->toIso8601(), 'P42W', __LINE__); 966 | assertSame(\Delight\Temporal\Duration::fromIso8601('P42W')->plus(\Delight\Temporal\Duration::fromIso8601('P51W'))->toIso8601(), 'P93W', __LINE__); 967 | assertSame(\Delight\Temporal\Duration::fromIso8601('P42W')->multipliedBy(4)->toIso8601(), 'P168W', __LINE__); 968 | 969 | echo "\n"; 970 | echo '[SUCCESS]'; 971 | 972 | function assertSame($a, $b, $line) { 973 | echo '[LINE ' . \sprintf('%04d', $line) . '] '; 974 | var_dump($a); 975 | 976 | if ($a !== $b) { 977 | echo ' [ERROR] '; 978 | var_dump($b); 979 | 980 | exit; 981 | } 982 | } 983 | --------------------------------------------------------------------------------