Add machine-readable dates in views (#3106)

This will allow to make some transformations on dates when needed.
See #3103 and #853
This commit is contained in:
Alexis Degrugillier
2020-07-14 10:51:45 +02:00
committed by GitHub
parent 877f5f539b
commit 8d8211b2a5
4 changed files with 7 additions and 6 deletions

View File

@@ -87,9 +87,11 @@ class FreshRSS_Entry extends Minz_Model {
public function date($raw = false) {
if ($raw) {
return $this->date;
} else {
return timestamptodate($this->date);
}
return timestamptodate($this->date);
}
public function machineReadableDate() {
return @date (DATE_ATOM, $this->date);
}
public function dateAdded($raw = false, $microsecond = false) {
if ($raw) {

View File

@@ -107,7 +107,7 @@
<?php } ?>
</li><?php
if ($bottomline_date) {
?><li class="item date"><?= $this->entry->date() ?></li><?php
?><li class="item date"><time datetime="<?= $this->entry->machineReadableDate() ?>"><?= $this->entry->date() ?></time>&nbsp;</li><?php
}
if ($bottomline_link) {
?><li class="item link"><a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>"><?= _i('link') ?></a></li><?php

View File

@@ -44,6 +44,6 @@
?></span><?php
endif;
?></a></li>
<?php if ($topline_date) { ?><li class="item date"><?= $this->entry->date() ?> </li><?php } ?>
<?php if ($topline_date) { ?><li class="item date"><time datetime="<?= $this->entry->machineReadableDate() ?>"><?= $this->entry->date() ?></time>&nbsp;</li><?php } ?>
<?php if ($topline_link) { ?><li class="item link"><a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>"><?= _i('link') ?></a></li><?php } ?>
</ul>

View File

@@ -62,8 +62,7 @@ $content_width = FreshRSS_Context::$user_conf->content_width;
endforeach;
echo ' — ';
endif;
echo $item->date();
?></div><div class="text">
?><time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time></div><div class="text">
<?= $item->content() ?>
</div></div>
</div>