Skip to content

Commit

Permalink
Try to proberly encode formatted date strings returned by strftime()
Browse files Browse the repository at this point in the history
  • Loading branch information
PhrozenByte committed Aug 29, 2020
1 parent 0e2b124 commit 4be1f6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"require": {
"php": ">=5.3.6",
"ext-mbstring": "*",
"twig/twig": "^1.36",
"symfony/yaml" : "^2.8",
"erusev/parsedown": "1.8.0-beta-7",
Expand Down
13 changes: 11 additions & 2 deletions lib/Pico.php
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,17 @@ public function parseFileMeta($rawContent, array $headers)
}

if (empty($meta['date_formatted'])) {
$dateFormat = $this->getConfig('date_format');
$meta['date_formatted'] = $meta['time'] ? utf8_encode(strftime($dateFormat, $meta['time'])) : '';
if ($meta['time']) {
$encodingList = mb_detect_order();
if ($encodingList === array('ASCII', 'UTF-8')) {
$encodingList[] = 'Windows-1252';
}

$rawFormattedDate = strftime($this->getConfig('date_format'), $meta['time']);
$meta['date_formatted'] = mb_convert_encoding($rawFormattedDate, 'UTF-8', $encodingList);
} else {
$meta['date_formatted'] = '';
}
}
} else {
// guarantee array key existance
Expand Down

0 comments on commit 4be1f6a

Please sign in to comment.