New option for Friendly Dates

Currently we have 'today only' and 'all days for the past week'. It would be nice if you add 'today + yesterday' in between :slight_smile:

1 Like

In the meantime, you could use an Eval Column:

XML
<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="date" foldertype="all" header="Modified" keyword="modifiedfriendly" maxstars="5" namerefresh="no" reversesort="no" title="Modified (friendly+)" type="7">yesterday = Now() - 60*60*24;

if (DatePart(modified, &quot;date&quot;) == DatePart(Now(), &quot;date&quot;))     return &quot;Today &quot; +     DatePart(modified, &quot;time&quot;);

if (DatePart(modified, &quot;date&quot;) == DatePart(yesterday, &quot;date&quot;)) return &quot;Yesterday &quot; + DatePart(modified, &quot;time&quot;);

return modified;</evalcolumn>
4 Likes

neat, but why it's present in Date/Time menu and not in "Edit folder format"?

It's a global setting.

It's there, it's just incorrectly showing as "Modified" instead of "Modified (friendly+)". Fixed in the next beta.

Finally got to try this trick, nice one! :slight_smile:

Faced a few problems/questions however:

  1. Sorting - the column is being sorted like a text (in alphabetic order), not like a date/time. Is there something we can do about it or is it a bug?
  2. Grouping is inappropriate as well.
  3. Any translations for the text should be done manually or is there a reliable & easy way to implement them?

Overall I still believe a new dedicated option for 'Friendly Dates' would just be better :thinking: What's interesting is how it's so obvious and easy feature but not in the list from the beginning :thinking: :grin:

Yes, both is possible. Check out the built-in eval column Modified (simple) (updated in 13.2.1) for details.

'Modified (simple)' column is broken as well in terms of sorting and grouping. Or maybe I'm having an outdated version of it?

<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="date" customgrouping="no" foldertype="all" header="Modified" keyword="modifiedsimple" maxstars="5" namerefresh="no" reversesort="yes" title="Modified (simple)" type="0">if (DatePart(modified, &quot;date&quot;) == DatePart(Now(), &quot;date&quot;))
	return DatePart(modified, &quot;time&quot;);
return DatePart(modified, &quot;date&quot;);</evalcolumn>

Current definition is this:

// sort by modified date	
if (operation == "sort")
	return modified;
// today?
today = Now();
mod_date = DatePart(modified, "date");
if (mod_date == DatePart(today, "date"))
{
	if (operation == "group")
		return LanguageStr(2195); // today
	return DatePart(modified, "time");
}
// if grouping, work out how old
if (operation == "group")
{
	if (modified > today)
		return LanguageStr(5793); // future
	mod_year = DatePart(modified, "yyyy");
	today_year = DatePart(today, "yyyy");
	if (mod_year == today_year)
		return LanguageStr(5800); // earlier this year
	if (mod_year == today_year - 1)
		return LanguageStr(5801); // last year
	return LanguageStr(5802); // a long time ago
}
return mod_date;
1 Like

Thanks! Pasting here an updated version of 'Modified (friendly+)' column:

<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="date" customgrouping="yes" foldertype="all" header="Modified" keyword="modifiedfriendlyplus" maxstars="5" namerefresh="no" reversesort="yes" title="Modified (friendly+)" type="7">if (operation != &quot;sort&quot;)
{
	today = Now();
	yesterday = today - 60 * 60 * 24;
	mod_date = DatePart(modified, &quot;date&quot;);

	if (mod_date == DatePart(today, &quot;date&quot;))
	{
		today_str = LanguageStr(2195); // or 5794 // &quot;Today&quot;

		if (operation == &quot;group&quot;)
			return &quot;1. &quot; + today_str;
		return today_str + &quot; &quot; + DatePart(modified, &quot;time&quot;);
	}
	if (mod_date == DatePart(yesterday, &quot;date&quot;))
	{
		yesterday_str = LanguageStr(2196); // or 5795 // &quot;Yesterday&quot;

		if (operation == &quot;group&quot;)
			return &quot;2. &quot; + yesterday_str;
		return yesterday_str + &quot; &quot; + DatePart(modified, &quot;time&quot;);
	}

	if (operation == &quot;group&quot;)
	{
		if (modified &gt; today)
			return &quot;0. &quot; + LanguageStr(5793); // &quot;Future&quot;

		mod_year = DatePart(modified, &quot;yyyy&quot;) as int;
		today_year = DatePart(today, &quot;yyyy&quot;) as int;
		//Output(&quot;mod_year = &quot; + mod_year + &quot;; today_year = &quot; + today_year);
		if (mod_year == today_year)
		{
			mod_month = DatePart(modified, &quot;M&quot;) as int;
			today_month = DatePart(today, &quot;M&quot;) as int;
			//Output(&quot;mod_month = &quot; + mod_month + &quot;; today_month = &quot; + today_month);
			if (mod_month == today_month)
			{
				mod_week = DatePart(modified, &quot;w&quot;) as int;
				today_week = DatePart(today, &quot;w&quot;) as int;
				//Output(&quot;mod_week = &quot; + mod_week + &quot;; today_week = &quot; + today_week);
				if (mod_week == today_week)
					return &quot;3. &quot; + LanguageStr(5796); // &quot;Earlier this week&quot;
				if (mod_week == (today_week - 1))
					return &quot;4. &quot; + LanguageStr(5797); // &quot;Last week&quot;

				return &quot;5. &quot; + LanguageStr(5798); // &quot;Earlier this month&quot;
			}
			if (mod_month == (today_month - 1)) // Note: If today&apos;s month is January, and Modified&apos;s is December, code will take &quot;Last year&quot; path, not this one. Should be changed?
				return &quot;6. &quot; + LanguageStr(5799); // &quot;Last month&quot;

			return &quot;7. &quot; + LanguageStr(5800); // &quot;Earlier this year&quot;
		}
		if (mod_year == (today_year - 1))
			return &quot;8. &quot; + LanguageStr(5801); // &quot;Last year&quot;
		return &quot;9. &quot; + LanguageStr(5802); // &quot;A long time ago&quot;
	}
}

return modified;
</evalcolumn>

Update1: Made group names numbered so that they can be sorted in a deterministic order (by actual age), not in alphabetic order.

Update2: Added explicit type casting and parenthesis, that fixed wrong grouping in my tests.

Bug ? My paste icon is not activating when copying the above xml.
image

nvm. was trying to paste it into Evaluator Groups, it pastes OK into Evaluator Columns.

Okay, updated it further. Now the code is splitted between EvalColumn (displaying of data) and EvalGroup (grouping of data):

column.xml
<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="date" customgrouping="yes" foldertype="all" header="Modified" keyword="modifiedfriendlyplus" maxstars="5" namerefresh="no" reversesort="yes" title="Modified (friendly+)" type="7">if (operation == &quot;display&quot;)
{
	today = Now();
	mod_date = DatePart(modified, &quot;date&quot;);
	if (mod_date == DatePart(today, &quot;date&quot;))
		return LanguageStr(5794) + &quot; &quot; + DatePart(modified, &quot;time&quot;); // &quot;Today&quot;

	yesterday = today - 60 * 60 * 24;
	if (mod_date == DatePart(yesterday, &quot;date&quot;))
		return LanguageStr(5795) + &quot; &quot; + DatePart(modified, &quot;time&quot;); // &quot;Yesterday&quot;
}

return modified;
</evalcolumn>
group_scheme.xml
<?xml version="1.0"?>
<evalgroupscheme desc="&quot;Modified (friendly+)&quot; group scheme" reverse="yes" scheme_name="modifiedfriendlyplus_group" sort="no">
	<eval>today = Now();
if (value &gt; today)
	return [ name = LanguageStr(5793); order = value; ]; // &quot;Future&quot;

mod_date = DatePart(value, &quot;date&quot;);
if (mod_date == DatePart(today, &quot;date&quot;))
	return [ name = LanguageStr(5794); order = value; ]; // &quot;Today&quot;

yesterday = today - 60 * 60 * 24;
if (mod_date == DatePart(yesterday, &quot;date&quot;))
	return [ name = LanguageStr(5795); order = value; ]; // &quot;Yesterday&quot;

mod_year = DatePart(value, &quot;yyyy&quot;) as int;
today_year = DatePart(today, &quot;yyyy&quot;) as int;
//Output(&quot;mod_year = &quot; + mod_year + &quot;; today_year = &quot; + today_year);
if (mod_year == today_year)
{
	mod_month = DatePart(value, &quot;M&quot;) as int;
	today_month = DatePart(today, &quot;M&quot;) as int;
	//Output(&quot;mod_month = &quot; + mod_month + &quot;; today_month = &quot; + today_month);
	if (mod_month == today_month)
	{
		mod_week = DatePart(value, &quot;w&quot;) as int;
		today_week = DatePart(today, &quot;w&quot;) as int;
		//Output(&quot;mod_week = &quot; + mod_week + &quot;; today_week = &quot; + today_week);
		if (mod_week == today_week)
			return [ name = LanguageStr(5796); order = value; ]; // &quot;Earlier this week&quot;
		if (mod_week == (today_week - 1))
			return [ name = LanguageStr(5797); order = value; ]; // &quot;Last week&quot;
		return [ name = LanguageStr(5798); order = value; ]; // &quot;Earlier this month&quot;
	}
	if (mod_month == (today_month - 1)) // Note: If today&apos;s month is January, and value&apos;s is December, code will take &quot;Last year&quot; path, not this one. Should be changed?
		return [ name = LanguageStr(5799); order = value; ]; // &quot;Last month&quot;
	return [ name = LanguageStr(5800); order = value; ]; // &quot;Earlier this year&quot;
}
if (mod_year == (today_year - 1))
	return [ name = LanguageStr(5801); order = value; ]; // &quot;Last year&quot;
return [ name = LanguageStr(5802); order = value; ]; // &quot;A long time ago&quot;
</eval>
	<groups enable="no" />
	<columns />
</evalgroupscheme>

Now we have correct group sorting with clean group names (no more numbers before text).

P.S. This could be done a bit easier if EvalColumn supported directly specifying group order in itself, upvote this feature request if you agree :slight_smile: