Fix Date meta header parsing with ISO-8601 datetime strings

Symfony YAML interprets ISO-8601 datetime strings and returns timestamps instead of the string. This behavior conforms to the YAML standard, i.e. this is no bug of Symfony YAML.

Fixes #336. Thanks @csholmq for reporting this.
pico-3.0-alpha
Daniel Rudolf 9 years ago
parent 0a4e7443d2
commit bbd8ef8847
  1. 12
      lib/Pico.php

@ -791,7 +791,17 @@ class Pico
}
if (!empty($meta['date'])) {
$meta['time'] = strtotime($meta['date']);
// workaround for issue #336
// Symfony YAML interprets ISO-8601 datetime strings and returns timestamps instead of the string
// this behavior conforms to the YAML standard, i.e. this is no bug of Symfony YAML
if (is_int($meta['date'])) {
$meta['time'] = $meta['date'];
$rawDateFormat = (date('H:i:s', $meta['time']) === '00:00:00') ? 'Y-m-d' : 'Y-m-d H:i:s';
$meta['date'] = date($rawDateFormat, $meta['time']);
} else {
$meta['time'] = strtotime($meta['date']);
}
$meta['date_formatted'] = utf8_encode(strftime($this->getConfig('date_format'), $meta['time']));
} else {
$meta['time'] = $meta['date_formatted'] = '';

Loading…
Cancel
Save