$ git clone http://thingshare.ion.nu/thingshare.git
commit c9b11cbf8361136cab8dc055ad1713caefbd3f89
Author: Alicia <...>
Date:   Sat Feb 6 19:04:01 2021 +0100

    Switched to relative time representation.

diff --git a/head.php b/head.php
index d7998e5..5b64336 100644
--- a/head.php
+++ b/head.php
@@ -26,7 +26,17 @@ function timeago($time)
 {
   $time=time()-strtotime($time);
   $unit='';
-  if($time>3600*47)
+  if($time>3600*24*365.25)
+  {
+    $time=round($time/(3600*24*365.25));
+    $unit='year';
+  }
+  elseif($time>3600*24*7)
+  {
+    $time=round($time/(3600*24*7));
+    $unit='week';
+  }
+  elseif($time>3600*47)
   {
     $time=round($time/(3600*24));
     $unit='day';
@@ -109,7 +119,6 @@ if($path[1]=='tag')
   <link rel="stylesheet" href="<?=BASEURL?>/x3dom.css" type="text/css" />
   <script src="<?=BASEURL?>/x3dom.debug.js"></script>
   <script src="<?=BASEURL?>/3dview.js"></script>
-  <script src="<?=BASEURL?>/time.js"></script>
   <script src="<?=BASEURL?>/web2.0.js"></script>
 </head>
 <body>
diff --git a/messages.php b/messages.php
index 74a98a0..7d94306 100644
--- a/messages.php
+++ b/messages.php
@@ -2,7 +2,7 @@
 /*
     This file is part of Thingshare, a federated system for sharing data for home manufacturing (e.g. 3D models to 3D print)
     https://thingshare.ion.nu/
-    Copyright (C) 2020  Alicia <...>
+    Copyright (C) 2020-2021  Alicia <...>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU Affero General Public License as published by
@@ -102,6 +102,7 @@ if($error=='' && ($path[2]!='new' || isset($_POST['to'])) && checknonce())
   }
   }} // Error checks (and blocking)
 }
+include_once('head.php');
 $messages='';
 $header='';
 // One view for overview, one view for thread/new
@@ -119,7 +120,7 @@ if(!isset($path[2]) || $path[2]=='') // Overview
     $messages.='<tr>';
     $messages.='  <td>'.$user.'</td>';
     $messages.='  <td><a href="'.BASEURL.'/messages/'.$chain.'"'.$aclass.'>'.$subjectline.'</a></td>';
-    $messages.='  <td><span class="time">'.htmlentities($row['sent']).'</span></td>';
+    $messages.='  <td><span class="time" title="'.htmlentities($row['sent']).' UTC">'.timeago($row['sent']).'</span></td>';
     $messages.='</tr>';
   }
 }
@@ -134,7 +135,8 @@ elseif($error=='' && $path[2]!='new') // Thread view
     $displayname=htmlentities(getdisplayname($row['sender']));
     $msg=$md->text(htmlentities($row['message']));
     $time=htmlentities($row['sent']);
-    $messages.='<div class="message'.($row['msgread']?'':' message_unread').'"><div class="message_sender"><a href="'.BASEURL.'/user/'.$sender.'" title="'.$sender.'">'.$displayname.'</a> <span class="time">'.$time.'</span></div>'.$msg.'</div>';
+    $timeago=timeago($row['sent']);
+    $messages.='<div class="message'.($row['msgread']?'':' message_unread').'"><div class="message_sender"><a href="'.BASEURL.'/user/'.$sender.'" title="'.$sender.'">'.$displayname.'</a> <span class="time" title="'.$time.' UTC">'.$timeago.'</span></div>'.$msg.'</div>';
   }
   mysqli_query($db, 'update messages set msgread=true where user='.(int)$_SESSION['id'].' and chain="'.$chain.'" order by sent asc');
 }
@@ -145,7 +147,6 @@ if($chain=='')
   $to=_('To:').' '.htmlentities($toname).'<br />';
 }
 if($error!=''){$info='<span class="error">'.$error.'</span>';}
-include_once('head.php');
 ?>
 <h1><?=(($subject=='')?_('Messages'):htmlentities($subject))?></h1>
 <?=$info?>
diff --git a/thing.php b/thing.php
index d6676f8..3bdff6f 100644
--- a/thing.php
+++ b/thing.php
@@ -131,7 +131,8 @@ function printcomments($comments, $level=0)
     }
     $msg=$md->text(htmlentities($comment['message']));
     $time=htmlentities($comment['sent']);
-    print('<div class="message" style="margin-left:'.($level*15).'px;" data-id="'.$comment['id'].'"><div class="message_sender"><a '.$senderhref.' title="'.$sender.'" name="comment'.$comment['id'].'">'.$displayname.'</a> <span class="time">'.$time.'</span></div><span>'.$msg.'</span><p>');
+    $timeago=timeago($comment['sent']);
+    print('<div class="message" style="margin-left:'.($level*15).'px;" data-id="'.$comment['id'].'"><div class="message_sender"><a '.$senderhref.' title="'.$sender.'" name="comment'.$comment['id'].'">'.$displayname.'</a> <span class="time" title="'.$time.' UTC">'.$timeago.'</span></div><span>'.$msg.'</span><p>');
     if(substr_count($sender, '@')>0 && isset($_SESSION['id']))
     {
       print('<a href="#" onclick="replyto(this.parentElement.parentElement); return false;">'._('Reply').'</a>');
@@ -154,7 +155,7 @@ function replyto(comment)
 // -->
 </script>
 <h1><?=$name?> <small class="subheader">by <?=$by?></small></h1>
-<small><?=sprintf(_('Published on %s under the license %s'), '<span class="time">'.htmlentities($thingobj['date']).'</span>', $license)?></small><br />
+<small><?=sprintf(_('Published %s under the license %s'), '<span class="time" title="'.htmlentities($thingobj['date']).' UTC">'.timeago($thingobj['date']).'</span>', $license)?></small><br />
 <?=$description?><br />
 <?=_('Tags:')?> <?=$tags?><br />
 <?=$files?>
diff --git a/time.js b/time.js
deleted file mode 100644
index 3fadaff..0000000
--- a/time.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-    This file is part of Thingshare, a federated system for sharing data for home manufacturing (e.g. 3D models to 3D print)
-    https://thingshare.ion.nu/
-    Copyright (C) 2020  Alicia <...>
-
-    See /COPYING for license text (AGPLv3+)
-*/
-window.addEventListener('load', function()
-{
-  // Convert times to local time
-  var pad=function(x)
-  {
-    x=x.toString();
-    if(x.length<2){x='0'+x;}
-    return x;
-  }
-  var offset=(new Date()).getTimezoneOffset();
-  var times=document.getElementsByClassName('time');
-  for(var i=0; i<times.length; ++i)
-  {
-    var t=new Date(times[i].textContent);
-    t.setTime(t.getTime()-offset*60000); // Time in milliseconds, offset in minutes
-    times[i].textContent=t.getFullYear()+'-'+pad(t.getMonth()+1)+'-'+pad(t.getDate())+' '+t.getHours()+':'+pad(t.getMinutes())+':'+pad(t.getSeconds());
-  }
-});