From a31019083ddb9a36ae4c2600d81c7edf77ca6275 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Sat, 19 Oct 2024 07:40:48 -0700 Subject: [PATCH] Standardise date to local date in one function for message headers. Try timezone but may switch back to offset if problems. --- Rocksolid_Light/common/header.php | 10 +++++ Rocksolid_Light/rocksolid/lib/message.inc.php | 38 ++++--------------- Rocksolid_Light/rocksolid/newsportal.php | 29 +++++++++++++- 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/Rocksolid_Light/common/header.php b/Rocksolid_Light/common/header.php index fcd8466..1c0c7e6 100644 --- a/Rocksolid_Light/common/header.php +++ b/Rocksolid_Light/common/header.php @@ -12,6 +12,16 @@ $CONFIG = include $config_file; $menulist = get_section_menu_array(); $linklist = file($config_dir . "links.conf", FILE_IGNORE_NEW_LINES); +// Set tzo if possible +?> + +'; if ($article_show["Subject"]) echo $text_header["subject"] . htmlspecialchars($head->subject) . "
"; @@ -462,17 +457,10 @@ function show_header($head, $group, $local_poster = false) if ((isset($head->organization)) && ($article_show["Organization"]) && ($head->organization != "")) echo $text_header["organization"] . html_parse(htmlspecialchars($head->organization)) . "
\n"; if ($article_show["Date"]) { - $ts = new DateTime(date($text_header["date_format"], $head->date), new DateTimeZone('UTC')); - $ts->add(DateInterval::createFromDateString($offset . ' minutes')); - if ($offset != 0) { - echo $text_header["date"] . $ts->format('D, j M Y H:i') . "
\n"; - } else { - echo $text_header["date"] . $ts->format($text_header["date_format"]) . "
\n"; - } - unset($ts); + // Try to use client timezone else default to UTC + $displaydate = get_date_for_client_timezone($head->date); + echo $displaydate; } - - // echo $text_header["date"].date($text_header["date_format"],$head->date)."
\n"; if ($article_show["Message-ID"]) { echo ' ' . $text_header["message-id"] . htmlspecialchars($head->id) . "
\n"; } @@ -517,21 +505,15 @@ function show_header($head, $group, $local_poster = false) function show_header_short($head, $group, $local_poster = false) { global $article_show, $text_header, $file_article, $file_thread, $attachment_show; - global $file_attachment, $anonym_address, $CONFIG, $config_name, $sitelink; + global $file_attachment, $CONFIG, $config_name, $sitelink; global $OVERRIDES; - if (isset($_COOKIE['tzo'])) { - $offset = $_COOKIE['tzo']; - } else { - $offset = intval($CONFIG['timezone']); - } echo '
'; echo ''; if ($article_show["Subject"]) { echo htmlspecialchars($head->subject) . "
"; } echo '
'; - $poster = address_decode($head->from, "nowhere"); if ($head->name != "") { $displayname = create_name_link($head->name, $head->from); } else { @@ -541,14 +523,10 @@ function show_header_short($head, $group, $local_poster = false) $displayname = htmlspecialchars($head->from); } } - $ts = new DateTime(date($text_header["date_format"], $head->date), new DateTimeZone('UTC')); - $ts->add(DateInterval::createFromDateString($offset . ' minutes')); - if ($offset != 0) { - $displaydate = $ts->format('D, j M Y H:i') . "
\n"; - } else { - $displaydate = $ts->format($text_header["date_format"]) . "
\n"; - } - unset($ts); + + // Try to use client timezone else default to UTC + $displaydate = get_date_for_client_timezone($head->date); + echo '
'; // Copy MID to clipboard (requires js) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 92ff39d..9854104 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1390,6 +1390,33 @@ function set_user_logged_in_cookies($name, $keys) setTimezone($client_time); + $displaydate = $datetime->format('D, j M Y H:i T'); + } else { + $datetime = new DateTime(date($text_header["date_format"], $date), new DateTimeZone('UTC')); + $datetime->add(DateInterval::createFromDateString($offset . ' minutes')); + if ($offset != 0) { + $offset_hours = ($offset / 60) * 100; + $displaydate = $datetime->format('D, j M Y H:i') . " " . sprintf('%05d', $offset_hours) . "
\n"; + } else { + $offset_hours = ($offset / 60) * 100; + $displaydate = $datetime->format($text_header["date_format"]) . "
\n"; + } + } + unset($datetime); + return $displaydate; +} function check_bbs_auth($username, $password, $sockip = null) { @@ -1688,7 +1715,7 @@ function get_section_menu_array() $newmenu[] = $menuentry; } } - return $newmenu; + return $newmenu; } function wipe_newsportal_spool_info($group)