MozillaZine


"X days old" / age column in email list views

User Help for Mozilla Thunderbird
dinoroar
 
Posts: 6
Joined: November 18th, 2019, 8:52 pm

Post Posted January 12th, 2021, 4:22 am

# "X days old" / age column in email list views

In my emails list views, in addition to the standard available metadata columns, I'd like to add a new column that simply shows a number (no text needed at all), indicating how many days ago the email was sent.

i.e:

* 0 = today
* 1 = yesterday
* 7 = a week ago
* etc...

This would be so much more efficient most of the time to get a good feel for how old the email is at a glace, without mentally parsing/thinking about how long ago a date was, or even needed to read / think about different units like week/months etc (as many other "age" messages do).

Is there any way to do this? Either with an add-on and/or some scripting I can do myself or anything?

I guess there's two options for when the numbers tick over:

* midnight
* 24 hour periods from each email's sent timestamp

...I don't really care which of these is used.

tanstaafl
Moderator

User avatar
 
Posts: 47409
Joined: July 30th, 2003, 5:06 pm

Post Posted January 12th, 2021, 6:57 am

The ColumnsWizard add-on at https://addons.thunderbird.net/en-US/th ... mnswizard/ lets you add custom columns, but that appears to be limited to ones based on headers.

I suggest you contact the add-on author and suggest they add Age in days as a header since that is already available in message filters as a pseudo header that can be tested. You could also try to lobby for the ability to add a custom column based on a simple javascript expression. In your case that expression would calculate the age in days.

sfhowes
 
Posts: 586
Joined: April 1st, 2012, 10:21 am

Post Posted January 12th, 2021, 10:45 am

This can be achieved in a rough way by setting View/Sort by/Date/Ascending or Descending/Grouped by Sort.

morat
 
Posts: 4273
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 12th, 2021, 6:58 pm

dinoroar wrote:some scripting I can do myself

Here is how to show the days old value next to the date in the message header pane.

Code: Select all
/* Thunderbird userChrome.js */

// Thunderbird 68 uses the messenger.xul page.
// Thunderbird 78 uses the messenger.xhtml page.

(function () {
  if (location == "chrome://messenger/content/messenger.xul" ||
      location == "chrome://messenger/content/messenger.xhtml") {
    try {
      var browser = document.getElementById("messagepane");
      browser.addEventListener("load", function () {
        var msgHdr = gFolderDisplay.selectedMessage;
        if (msgHdr) {
          var milliseconds = new Date().getTime() - msgHdr.dateInSeconds * 1000;
          var days = Math.floor(milliseconds / (24 * 60 * 60 * 1000));
          var label = document.getElementById("dateLabel");
          label.textContent += ", " + days + " days old";
        }
      }, true);
    } catch (e) {
      Components.utils.reportError(e);
    }
  }
})();

Instructions:

1. install userChromeJS extension
2. close email client
3. create or edit the userChrome.js file in the chrome folder
4. open email client

userChromeJS by jikamens (compatible with TB 68 and TB 78)
http://addons.thunderbird.net/thunderbird/addon/986610

Return to Thunderbird Support


Who is online

Users browsing this forum: WaltS48 and 3 guests