aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2020-07-14 10:51:45 +0200
committerGravatar GitHub <noreply@github.com> 2020-07-14 10:51:45 +0200
commit8d8211b2a5fa997bce06d7ae0c6f7cf37f97b245 (patch)
tree0cb2f8da03c8470a14c411cf2477be0e2047255b
parent877f5f539b82db2e59ecf7257fce18dc9245f310 (diff)
Add machine-readable dates in views (#3106)
This will allow to make some transformations on dates when needed. See #3103 and #853
-rw-r--r--app/Models/Entry.php6
-rw-r--r--app/views/helpers/index/normal/entry_bottom.phtml2
-rw-r--r--app/views/helpers/index/normal/entry_header.phtml2
-rw-r--r--app/views/index/reader.phtml3
4 files changed, 7 insertions, 6 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 14eacbe78..75d8da12c 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -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) {
diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml
index fa2b8f036..1c1a1c8f1 100644
--- a/app/views/helpers/index/normal/entry_bottom.phtml
+++ b/app/views/helpers/index/normal/entry_bottom.phtml
@@ -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
diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml
index 1bca764d4..df4abd7e5 100644
--- a/app/views/helpers/index/normal/entry_header.phtml
+++ b/app/views/helpers/index/normal/entry_header.phtml
@@ -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>
diff --git a/app/views/index/reader.phtml b/app/views/index/reader.phtml
index 644cd09c6..32e2bee04 100644
--- a/app/views/index/reader.phtml
+++ b/app/views/index/reader.phtml
@@ -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>