diff options
Diffstat (limited to 'vendor/php81_bc/strftime')
-rw-r--r-- | vendor/php81_bc/strftime/.gitignore | 1 | ||||
-rw-r--r-- | vendor/php81_bc/strftime/src/IntlLocaleFormatter.php | 4 | ||||
-rw-r--r-- | vendor/php81_bc/strftime/src/php-8.1-strftime.php | 19 |
3 files changed, 15 insertions, 9 deletions
diff --git a/vendor/php81_bc/strftime/.gitignore b/vendor/php81_bc/strftime/.gitignore index a5b812048..659557e1b 100644 --- a/vendor/php81_bc/strftime/.gitignore +++ b/vendor/php81_bc/strftime/.gitignore @@ -23,6 +23,7 @@ Thumbs.db ####################### /.vscode /composer.lock +.phpunit.result.cache # vim *~ *.swp diff --git a/vendor/php81_bc/strftime/src/IntlLocaleFormatter.php b/vendor/php81_bc/strftime/src/IntlLocaleFormatter.php index 5bb62e425..783a0c103 100644 --- a/vendor/php81_bc/strftime/src/IntlLocaleFormatter.php +++ b/vendor/php81_bc/strftime/src/IntlLocaleFormatter.php @@ -14,9 +14,9 @@ class IntlLocaleFormatter extends AbstractLocaleFormatter /** @var string[] strftime to ICU placeholders */ protected $formats = [ - '%a' => 'EEE', // An abbreviated textual representation of the day Sun through Sat + '%a' => 'ccc', // An abbreviated textual representation of the day Sun through Sat '%A' => 'EEEE', // A full textual representation of the day Sunday through Saturday - '%b' => 'MMM', // Abbreviated month name, based on the locale Jan through Dec + '%b' => 'LLL', // Abbreviated month name, based on the locale Jan through Dec '%B' => 'MMMM', // Full month name, based on the locale January through December '%h' => 'MMM', // Abbreviated month name, based on the locale (an alias of %b) Jan through Dec ]; diff --git a/vendor/php81_bc/strftime/src/php-8.1-strftime.php b/vendor/php81_bc/strftime/src/php-8.1-strftime.php index f8a8c79cd..75a6bb351 100644 --- a/vendor/php81_bc/strftime/src/php-8.1-strftime.php +++ b/vendor/php81_bc/strftime/src/php-8.1-strftime.php @@ -2,10 +2,13 @@ namespace PHP81_BC; use DateTime; - use DateTimeInterface; use DateTimeZone; + use DateTimeInterface; use Exception; use InvalidArgumentException; + use Locale; + use PHP81_BC\strftime\DateLocaleFormatter; + use PHP81_BC\strftime\IntlLocaleFormatter; /** * Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible) @@ -22,7 +25,9 @@ * * @param string $format Date format * @param integer|string|DateTime $timestamp Timestamp + * @param string|null $locale locale * @return string + * @throws InvalidArgumentException * @author BohwaZ <https://bohwaz.net/> */ function strftime (string $format, $timestamp = null, ?string $locale = null) : string { @@ -34,15 +39,15 @@ } catch (Exception $e) { throw new InvalidArgumentException('$timestamp argument is neither a valid UNIX timestamp, a valid date-time string or a DateTime object.', 0, $e); } - } - $timestamp->setTimezone(new DateTimeZone(date_default_timezone_get())); + $timestamp->setTimezone(new DateTimeZone(date_default_timezone_get())); + } if (class_exists('\\IntlDateFormatter') && !isset($_SERVER['STRFTIME_NO_INTL'])) { - $locale = \Locale::canonicalize($locale ?? setlocale(LC_TIME, '0')); - $locale_formatter = new \PHP81_BC\strftime\IntlLocaleFormatter($locale); + $locale = Locale::canonicalize($locale ?? (Locale::getDefault() ?? setlocale(LC_TIME, '0'))); + $locale_formatter = new IntlLocaleFormatter($locale); } else { - $locale_formatter = new \PHP81_BC\strftime\DateLocaleFormatter($locale); + $locale_formatter = new DateLocaleFormatter($locale); } // Same order as https://www.php.net/manual/en/function.strftime.php @@ -151,7 +156,7 @@ case '#': case '-': // remove leading zeros but keep last char if also zero - return preg_replace('/^0+(?=.)/', '', $result); + return preg_replace('/^[0\s]+(?=.)/', '', $result); } return $result; |