Browse Source

Change dates to ISO 8601-like, fix deprecation of strfdate() in PHP 8.1, fix non-GMT dates

Unfortunately this means there are two format strings needed when using JS for local time.
main
discomrade 2 years ago
committed by -
parent
commit
e8251ade6a
  1. 6
      inc/announcements.php
  2. 24
      inc/config.php
  3. 2
      inc/lib/twig/extensions/Extension/Tinyboard.php
  4. 4
      inc/mod/pages.php
  5. 2
      templates/important.html
  6. 2
      templates/main.js
  7. 2
      templates/post/time.html
  8. 2
      templates/themes/catalog/catalog.html
  9. 2
      templates/themes/sitemap/sitemap.xml
  10. 2
      tools/public_statistics_cli.php

6
inc/announcements.php

@ -64,7 +64,7 @@ class Announcements {
$announcements = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($announcements as &$announce) {
$announce['date_formated'] = strftime($config['announcements']['date_format'], $announce['date']);
$announce['date_formated'] = gmdate($config['announcements']['date_format'], $announce['date']);
}
$announcements_short = Element('announcements.html', array(
@ -89,7 +89,7 @@ class Announcements {
$announcements = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($announcements as &$announce) {
$announce['date_formated'] = strftime($config['announcements']['date_format'], $announce['date']);
$announce['date_formated'] = gmdate($config['announcements']['date_format'], $announce['date']);
}
// Generate page for full list of announcements
@ -137,7 +137,7 @@ class Announcements {
if($filter_staff)
$announce['username'] = '?';
$announce['date_formated'] = strftime($date_format, $announce['date']);
$announce['date_formated'] = gmdate($date_format, $announce['date']);
$json = json_encode($announce);
$out ? fputs($out, $json) : print($json);

24
inc/config.php

@ -987,7 +987,7 @@
$config['announcements']['show_count'] = 3;
// Date format for announcements.
$config['announcements']['date_format'] = '%m/%d/%Y';
$config['announcements']['date_format'] = 'Y-m-d';
// Create full announcements page.
$config['announcements']['page'] = true;
@ -1006,11 +1006,16 @@
// Timezone to use for displaying dates/times.
$config['timezone'] = 'America/Los_Angeles';
// The format string passed to strftime() for displaying dates.
// http://www.php.net/manual/en/function.strftime.php
$config['post_date'] = '%m/%d/%y (%a) %H:%M:%S';
// Same as above, but used for "you are banned' pages.
$config['ban_date'] = '%A %e %B, %Y';
// The format string passed to date() for displaying dates.
// https://www.php.net/manual/en/datetime.format.php
$config['post_date'] = 'Y-m-d (D) H:i:s';
// The format string passed to JavaScript's strfdate() for displaying local dates.
// https://www.php.net/manual/en/function.strftime.php
$config['post_date_js'] = '%F (%a) %T';
// Same as above, but used for catalog tooltips.
$config['catalog_date'] = 'M d H:i';
// Same as above, but used for 'you are banned' pages.
$config['ban_date'] = 'l j F, Y';
// The names on the post buttons. (On most imageboards, these are both just "Post").
$config['button_newtopic'] = _('New Topic');
@ -2044,10 +2049,9 @@
$config['public_stats']['hourly'] = false;
// Include the current hour in public stats.
$config['public_stats']['realtime'] = false;
// The format string passed to strftime() for displaying dates.
// http://www.php.net/manual/en/function.strftime.php
//$config['public_stat']['date'] = '%m/%d/%y (%a) %l %P';
$config['public_stats']['date'] = '<time datetime="%Y-%m-%dT%H:%M:%SZ">%Y-%m-%dT%H:%M:%S</time>';
// The format string passed to date() for displaying dates.
// https://www.php.net/manual/en/datetime.format.php
$config['public_stats']['date'] = 'Y-m-d\TH:i:s\Z';
/*
* ====================

2
inc/lib/twig/extensions/Extension/Tinyboard.php

@ -81,7 +81,7 @@ function twig_remove_whitespace_filter($data) {
}
function twig_date_filter($date, $format) {
return gmstrftime($format, $date);
return gmdate($format, $date);
}
function twig_hasPermission_filter($mod, $permission, $board = null) {

4
inc/mod/pages.php

@ -1010,7 +1010,7 @@ function mod_announcements() {
$announcements = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($announcements as &$announce) {
$announce['date_formated'] = strftime($config['announcements']['date_format'], $announce['date']);
$announce['date_formated'] = gmdate($config['announcements']['date_format'], $announce['date']);
}
// Display announcement page
@ -3408,7 +3408,7 @@ function mod_config($board_config = false) {
}
if (!empty($config_append)) {
$config_append = "\n// Changes made via web editor by \"" . $mod['username'] . "\" @ " . date('r') . ":\n" . $config_append . "\n";
$config_append = "\n// Changes made via web editor by \"" . $mod['username'] . "\" @ " . gmdate('r') . ":\n" . $config_append . "\n";
if (!is_file($config_file))
$config_append = "<?php\n\n$config_append";
if (!@file_put_contents($config_file, $config_append, FILE_APPEND)) {

2
templates/important.html

@ -1,7 +1,7 @@
<div class="ban">
{% for telegram in telegrams %}
<div style="padding: 10px;">
<cite><time datetime="{{ telegram.created_at|date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}">{{ post.time|date(config.post_date) }}</time></cite>
<cite><time datetime="{{ telegram.created_at|date('Y-m-d\\TH:i:s') }}{{ timezone() }}">{{ post.time|date(config.post_date) }}</time></cite>
<p>{{ telegram.message }}</p>
</div>
<hr>

2
templates/main.js

@ -406,7 +406,7 @@ function ready() {
{% endverbatim %}
var post_date = "{{ config.post_date }}";
var post_date = "{{ config.post_date_js }}";
var max_images = {{ config.max_images }};
onready(init);

2
templates/post/time.html

@ -1 +1 @@
<time datetime="{{ post.time|date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}">{{ post.time|date(config.post_date) }}</time>
<time datetime="{{ post.time|date('Y-m-d\\TH:i:s') }}{{ timezone() }}">{{ post.time|date(config.post_date) }}</time>

2
templates/themes/catalog/catalog.html

@ -62,7 +62,7 @@
{% else %}
<img src="{{post.file}}"
{% endif %}
id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}">
id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date(config.catalog_date)}}">
</a>
<div class="replies">
<style>strong > i, strong > img { margin-left: 4px;}</style>

2
templates/themes/sitemap/sitemap.xml

@ -10,7 +10,7 @@
{% for thread in thread_list %}
<url>
<loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ link_for(thread) }}</loc>
<lastmod>{{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}</lastmod>
<lastmod>{{ thread.lastmod | date('Y-m-d\\TH:i:s') }}{{ timezone() }}</lastmod>
<changefreq>{{ settings.changefreq }}</changefreq>
</url>
{% endfor %}

2
tools/public_statistics_cli.php

@ -56,7 +56,7 @@ function statpage($board = false, $boards, $stat_file) {
'mod' => false,
'hide_dashboard_link' => true,
'title' => _("Statistics") . ($board?" for /" . $board . "/":""),
'subtitle' => _("Last Updated : ") . gmstrftime($config['public_stats']['date']),
'subtitle' => _("Last Updated : ") . '<time datetime="' . gmdate($config['public_stats']['date']) . '">' . gmdate($config['public_stats']['date']) . '</time>',
'nojavascript' => true,
'boardlist' => createBoardlist(false),
'body' => Element('mod/statistics.html', array(

Loading…
Cancel
Save