CarbonTimezoneTrait.php 736 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. use Carbon\CarbonInterface;
  12. trait CarbonTimezoneTrait
  13. {
  14. public function toAppTz(bool $shift = false, string $tz = 'UTC'): CarbonInterface
  15. {
  16. return $shift
  17. ? $this->shiftTimezone($tz)
  18. : $this->timezone($tz);
  19. }
  20. public function copyWithAppTz(bool $shift = false, string $tz = 'UTC'): CarbonInterface
  21. {
  22. return ($shift
  23. ? $this->shiftTimezone($tz)
  24. : $this->timezone($tz)
  25. )->copy();
  26. }
  27. }