Skip to content

Commit 4739030

Browse files
committed
updated strftime lib. fixes dokuwiki#4449
1 parent 396ae2b commit 4739030

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@
337337
"source": {
338338
"type": "git",
339339
"url": "https://github.com/alphp/strftime.git",
340-
"reference": "88e98f00b5d9247e8168c1eb528ab138fbf743d2"
340+
"reference": "dcd30543db16c9b4ba095f6bf32ac16f15eb9448"
341341
},
342342
"dist": {
343343
"type": "zip",
344-
"url": "https://api.github.com/repos/alphp/strftime/zipball/88e98f00b5d9247e8168c1eb528ab138fbf743d2",
345-
"reference": "88e98f00b5d9247e8168c1eb528ab138fbf743d2",
344+
"url": "https://api.github.com/repos/alphp/strftime/zipball/dcd30543db16c9b4ba095f6bf32ac16f15eb9448",
345+
"reference": "dcd30543db16c9b4ba095f6bf32ac16f15eb9448",
346346
"shasum": ""
347347
},
348348
"require": {
@@ -354,7 +354,7 @@
354354
"suggest": {
355355
"ext-intl": "For proper locale aware output"
356356
},
357-
"time": "2024-01-26T18:19:38+00:00",
357+
"time": "2025-05-20T20:04:36+00:00",
358358
"type": "library",
359359
"installation-source": "dist",
360360
"autoload": {

vendor/composer/installed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'dokuwiki/dokuwiki',
44
'pretty_version' => 'dev-master',
55
'version' => 'dev-master',
6-
'reference' => '59a6ba95c8c7b11b3a1e341c41942ec083784be0',
6+
'reference' => '396ae2b1e4ac18cd8a3de8ba055f983a807687dc',
77
'type' => 'project',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -22,7 +22,7 @@
2222
'dokuwiki/dokuwiki' => array(
2323
'pretty_version' => 'dev-master',
2424
'version' => 'dev-master',
25-
'reference' => '59a6ba95c8c7b11b3a1e341c41942ec083784be0',
25+
'reference' => '396ae2b1e4ac18cd8a3de8ba055f983a807687dc',
2626
'type' => 'project',
2727
'install_path' => __DIR__ . '/../../',
2828
'aliases' => array(),
@@ -79,7 +79,7 @@
7979
'php81_bc/strftime' => array(
8080
'pretty_version' => 'dev-fallback-intl',
8181
'version' => 'dev-fallback-intl',
82-
'reference' => '88e98f00b5d9247e8168c1eb528ab138fbf743d2',
82+
'reference' => 'dcd30543db16c9b4ba095f6bf32ac16f15eb9448',
8383
'type' => 'library',
8484
'install_path' => __DIR__ . '/../php81_bc/strftime',
8585
'aliases' => array(),

vendor/php81_bc/strftime/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Thumbs.db
2323
#######################
2424
/.vscode
2525
/composer.lock
26+
.phpunit.result.cache
2627
# vim
2728
*~
2829
*.swp

vendor/php81_bc/strftime/src/IntlLocaleFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class IntlLocaleFormatter extends AbstractLocaleFormatter
1414

1515
/** @var string[] strftime to ICU placeholders */
1616
protected $formats = [
17-
'%a' => 'EEE', // An abbreviated textual representation of the day Sun through Sat
17+
'%a' => 'ccc', // An abbreviated textual representation of the day Sun through Sat
1818
'%A' => 'EEEE', // A full textual representation of the day Sunday through Saturday
19-
'%b' => 'MMM', // Abbreviated month name, based on the locale Jan through Dec
19+
'%b' => 'LLL', // Abbreviated month name, based on the locale Jan through Dec
2020
'%B' => 'MMMM', // Full month name, based on the locale January through December
2121
'%h' => 'MMM', // Abbreviated month name, based on the locale (an alias of %b) Jan through Dec
2222
];

vendor/php81_bc/strftime/src/php-8.1-strftime.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
namespace PHP81_BC;
33

44
use DateTime;
5-
use DateTimeInterface;
65
use DateTimeZone;
6+
use DateTimeInterface;
77
use Exception;
88
use InvalidArgumentException;
9+
use Locale;
10+
use PHP81_BC\strftime\DateLocaleFormatter;
11+
use PHP81_BC\strftime\IntlLocaleFormatter;
912

1013
/**
1114
* Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible)
@@ -22,7 +25,9 @@
2225
*
2326
* @param string $format Date format
2427
* @param integer|string|DateTime $timestamp Timestamp
28+
* @param string|null $locale locale
2529
* @return string
30+
* @throws InvalidArgumentException
2631
* @author BohwaZ <https://bohwaz.net/>
2732
*/
2833
function strftime (string $format, $timestamp = null, ?string $locale = null) : string {
@@ -34,15 +39,15 @@ function strftime (string $format, $timestamp = null, ?string $locale = null) :
3439
} catch (Exception $e) {
3540
throw new InvalidArgumentException('$timestamp argument is neither a valid UNIX timestamp, a valid date-time string or a DateTime object.', 0, $e);
3641
}
37-
}
3842

39-
$timestamp->setTimezone(new DateTimeZone(date_default_timezone_get()));
43+
$timestamp->setTimezone(new DateTimeZone(date_default_timezone_get()));
44+
}
4045

4146
if (class_exists('\\IntlDateFormatter') && !isset($_SERVER['STRFTIME_NO_INTL'])) {
42-
$locale = \Locale::canonicalize($locale ?? setlocale(LC_TIME, '0'));
43-
$locale_formatter = new \PHP81_BC\strftime\IntlLocaleFormatter($locale);
47+
$locale = Locale::canonicalize($locale ?? (Locale::getDefault() ?? setlocale(LC_TIME, '0')));
48+
$locale_formatter = new IntlLocaleFormatter($locale);
4449
} else {
45-
$locale_formatter = new \PHP81_BC\strftime\DateLocaleFormatter($locale);
50+
$locale_formatter = new DateLocaleFormatter($locale);
4651
}
4752

4853
// Same order as https://www.php.net/manual/en/function.strftime.php
@@ -151,7 +156,7 @@ function strftime (string $format, $timestamp = null, ?string $locale = null) :
151156
case '#':
152157
case '-':
153158
// remove leading zeros but keep last char if also zero
154-
return preg_replace('/^0+(?=.)/', '', $result);
159+
return preg_replace('/^[0\s]+(?=.)/', '', $result);
155160
}
156161

157162
return $result;

0 commit comments

Comments
 (0)