summaryrefslogtreecommitdiff
path: root/vendor/thecodingmachine/safe/lib/DateTime.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2024-12-10 05:22:37 +0000
committerAndrew Dolgov <fox@fakecake.org>2024-12-10 05:22:37 +0000
commit0ef2dd7175248e1116a867e0a86579d9f6ca16eb (patch)
tree452fc6e3391544b209ea075d587935e7ab42e714 /vendor/thecodingmachine/safe/lib/DateTime.php
parentf15db7b9610467aa29f6441361fdc4e6c90deaa1 (diff)
parent3860435cba19cf2cd9c86dcc5d8938198c6b6736 (diff)
Merge branch 'feature/alpine_3.21-and-php_8.4' into 'master'
Bump to Alpine 3.21 and PHP 8.4, raise the minimum to PHP 8.2 See merge request tt-rss/tt-rss!85
Diffstat (limited to 'vendor/thecodingmachine/safe/lib/DateTime.php')
-rw-r--r--vendor/thecodingmachine/safe/lib/DateTime.php81
1 files changed, 0 insertions, 81 deletions
diff --git a/vendor/thecodingmachine/safe/lib/DateTime.php b/vendor/thecodingmachine/safe/lib/DateTime.php
deleted file mode 100644
index 56eb809f8..000000000
--- a/vendor/thecodingmachine/safe/lib/DateTime.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-namespace Safe;
-
-use DateInterval;
-use DateTimeInterface;
-use DateTimeZone;
-use Safe\Exceptions\DatetimeException;
-
-/** this class implements a safe version of the Datetime class */
-class DateTime extends \DateTime
-{
- //switch from regular datetime to safe version
- private static function createFromRegular(\DateTime $datetime): self
- {
- return new self($datetime->format('Y-m-d H:i:s.u'), $datetime->getTimezone());
- }
-
- /**
- * @param string $format
- * @param string $time
- * @param DateTimeZone|null $timezone
- * @throws DatetimeException
- */
- public static function createFromFormat($format, $time, $timezone = null): self
- {
- $datetime = \DateTime::createFromFormat($format, $time, $timezone);
- if ($datetime === false) {
- throw DatetimeException::createFromPhpError();
- }
- return self::createFromRegular($datetime);
- }
-
- /**
- * @param DateTimeInterface $datetime2 The date to compare to.
- * @param boolean $absolute [optional] Whether to return absolute difference.
- * @return DateInterval The DateInterval object representing the difference between the two dates.
- * @throws DatetimeException
- */
- public function diff($datetime2, $absolute = false): DateInterval
- {
- /** @var \DateInterval|false $result */
- $result = parent::diff($datetime2, $absolute);
- if ($result === false) {
- throw DatetimeException::createFromPhpError();
- }
- return $result;
- }
-
- /**
- * @param string $modify A date/time string. Valid formats are explained in <a href="https://secure.php.net/manual/en/datetime.formats.php">Date and Time Formats</a>.
- * @return DateTime Returns the DateTime object for method chaining.
- * @throws DatetimeException
- */
- public function modify($modify): self
- {
- /** @var DateTime|false $result */
- $result = parent::modify($modify);
- if ($result === false) {
- throw DatetimeException::createFromPhpError();
- }
- return $result;
- }
-
- /**
- * @param int $year
- * @param int $month
- * @param int $day
- * @return DateTime
- * @throws DatetimeException
- */
- public function setDate($year, $month, $day): self
- {
- /** @var DateTime|false $result */
- $result = parent::setDate($year, $month, $day);
- if ($result === false) {
- throw DatetimeException::createFromPhpError();
- }
- return $result;
- }
-}