Skip to content

Commit

Permalink
smarty API: Refactor 4489eea ff
Browse files Browse the repository at this point in the history
  • Loading branch information
ophian committed Jul 29, 2024
1 parent 4489eea commit 536b8c4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/functions_smarty.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,14 @@ function serendipity_smarty_rss_getguid($params, $template) {
* @return
*/
function serendipity_smarty_formatTime($timestamp, $format, $useOffset = true, $detectTimestamp = false, $useDate = false) {
if ($detectTimestamp !== false && (($detectTimestamp === 'DigitalDateCreated' && strlen($timestamp) === 8) || stristr($detectTimestamp, 'date') === false)) {
if ($detectTimestamp !== false && stristr($detectTimestamp, 'date') === false) {
return $timestamp;
}
// Here we either have valid timestamps or datetime strings since they can happen in 'DigitalDateCreated', 'ExpirationDate' and ...?
if (is_string($timestamp) && strlen($timestamp) === 8) {
$dateTime = \DateTime::createFromFormat('Ymd|', $timestamp);
$timestamp = $dateTime->getTimestamp();
}

if (defined($format)) {
return serendipity_formatTime(constant($format), $timestamp, $useOffset, $useDate);
Expand Down

0 comments on commit 536b8c4

Please sign in to comment.