Concise Time Notation (27d 6h 56m) evaluator tooltip/column

This is limited to days, so you will not see the break down into years and months. It aims to show 3 fields, newer files will show the seconds (1h 1m 1s) and once a day or more is reached the seconds will disappear (1d 1h 1m). If any one of the 3 fields are 0 they will be omitted. So you can expect to see '5h' or '30d 45m'. There is no limit of days so the day value can get high for old items.

Note the evaluator may be better fit as a tooltip rather than a column. A tooltip has a limited time it is visible, meaning the time difference calculated will be fresh and accurate. Compared to a column, the column could be there for hours/days without a refresh and when you come back to it would need to be refreshed to show the correct information. So keep that in mind if you choose to use as a column.

Tooltip version: (FYI: both versions are being compared with the modified column)

{= seconds = DateDiff("s", modified, Now());
s = seconds Mod 60;
m = seconds / 60 Mod 60;
h = seconds / 60 / 60 Mod 24;
d = seconds / 60 / 60 / 24;
ss = (d > 0 || s == 0) ? "" : s + "s";
mm = (m == 0) ? "" : m + "m ";
hh = (h == 0) ? "" : h + "h ";
dd = (d == 0) ? "" : d + "d ";
return Trim(dd + hh + mm + ss) + " ago"; =}

Column version:

<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="no" autorefresh="yes" foldertype="all" graphcol="#ff8000" header="Modified (ctn)" keyword="modifiedctn" maxstars="5" namerefresh="no" reversesort="no" title="Modified (ctn)" type="0">seconds = DateDiff(&quot;s&quot;, modified, Now());
s = seconds Mod 60;
m = seconds / 60 Mod 60;
h = seconds / 60 / 60 Mod 24;
d = seconds / 60 / 60 / 24;
ss = (d &gt; 0 || s == 0) ? &quot;&quot; : s + &quot;s&quot;;
mm = (m == 0) ? &quot;&quot; : m + &quot;m &quot;;
hh = (h == 0) ? &quot;&quot; : h + &quot;h &quot;;
dd = (d == 0) ? &quot;&quot; : d + &quot;d &quot;;
return Trim(dd + hh + mm + ss);</evalcolumn>

The difference between the two is the tooltip version appends 'ago' to the end (5d 16h 32m ago) and the column does not.

2023-10-21_235001

7 Likes

I adapted your script to calculate time between now and shooting time of pictures.

Evaluator column:

<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="image" foldertype="all" graphcol="#ff8000" header="Date taken" keyword="shootingtimecount" maxstars="5" namerefresh="yes" reversesort="no" title="Date taken (count)" type="0">// Calculate the number of days/hours/minutes/seconds since the shooting date

if ((!IsSet(ext)) || (ext!=&quot;jpg&quot;)) { return };
	if (!IsSet(shootingtime)) { return };
	{
		seconds = DateDiff(&quot;s&quot;, shootingtime, Now());
		s = seconds Mod 60;
		m = seconds / 60 Mod 60;
		h = seconds / 60 / 60 Mod 24;
		d = seconds / 60 / 60 / 24;
		ss = (d &gt; 0 || s == 0) ? &quot;&quot; : s + &quot;s&quot;;
		mm = (m == 0) ? &quot;&quot; : m + &quot;m &quot;;
		hh = (h == 0) ? &quot;&quot; : h + &quot;h &quot;;
		dd = (d == 0) ? &quot;&quot; : d + &quot;d &quot;;
		return Trim(dd + hh + mm + ss);
	}
</evalcolumn>
5 Likes