mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-11 23:34:26 +02:00
Add support for more datetime formats
- Unix Timestamp - RFC 3339 extended + timezone name in square brackets - Address https://github.com/friendica/friendica/issues/14647#issuecomment-2719430131
This commit is contained in:
parent
0aa350f1c8
commit
6f159e69be
2 changed files with 85 additions and 2 deletions
|
@ -117,7 +117,7 @@ class DateTimeFormat
|
|||
$tz_to = 'UTC';
|
||||
}
|
||||
|
||||
if (($s === '') || (!is_string($s))) {
|
||||
if ($s === '') {
|
||||
$s = 'now';
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,8 @@ class DateTimeFormat
|
|||
}
|
||||
|
||||
try {
|
||||
$d = new DateTime($s, $from_obj);
|
||||
$d = DateTime::createFromFormat('U', $s, $from_obj)
|
||||
?: new DateTime($s, $from_obj);
|
||||
} catch (Exception $e) {
|
||||
try {
|
||||
$d = new DateTime(self::fix($s), $from_obj);
|
||||
|
@ -176,6 +177,7 @@ class DateTimeFormat
|
|||
$pregPatterns = [
|
||||
['#(\w+), (\d+ \w+ \d+) (\d+:\d+:\d+) (.+)#', '$2 $3 $4'],
|
||||
['#(\d+:\d+) (\w+), (\w+) (\d+), (\d+)#', '$1 $2 $3 $4 $5'],
|
||||
['#\[[^\]]*\]#', ''], // 2025-03-07T08:54:14.341+01:00[Europe/Berlin]
|
||||
];
|
||||
|
||||
foreach ($pregPatterns as $pattern) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue