To improve the display of messages at /messages, Berdir and I discussed displaying different date/time formats based on the time range (that's what Gmail does). I also took a look at how Gmail does it to get some more inspiration. I'm creating this issue thread at Berdir's request.

Here are my suggestions for formats to use based on how old a given message is:

Current hour: 25 min ago
Current day (but not within the hour): 10:30 am
Current year (but not on the same day): Nov 25
Prior years (not the current year): 11/25/08

Ideally, these would be configurable by the site admin for all four time ranges. Or alternately, is there any way to have the PM module add its own date and time formats (which the site admin could then change at admin/config/regional/date-time)?

--Ben

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
6.72 KB

This is a first patch, date formats are implemented as suggested. Note that you need to run the new update function to set the default formats, you can then change them in the date and time settings page.

BenK’s picture

Hey Berdir,

Thanks for this... the patch is working great! In terms of functionality, everything is working perfectly. Here are my notes:

1. Should we have a "Privatemsg: Current hour" setting on the date and time page? Even though I love the "time ago" format for this, this setting would allow another site admin to change this to an actual time if they preferred.

2. In the "Privatemsg: Other years" format, can we remove the leading zeros on the month and day (or else give this as an additional option)? Currently, January 1, 2007 displays as: 01/05/2007. In the U.S., this would more commonly be seen as: 1/5/2007 or 1/5/07. Actually, it would also be nice to have an option to specify the year part as either 4-digit or two-digit.

3. How about making all options available for all formats ("Privatemsg: Current day", "Privatemsg: Current year," and "Privatemsg: Other years")? For instance, if a site admin wants to be able to use the "Current year" format for the "Current day" as well, it might be nice to have those options available.

--Ben

BenK’s picture

Status: Needs review » Needs work
Berdir’s picture

1. The problem is that the "xy ago" thing is something completely else than the others. The current hour one uses http://api.drupal.org/api/drupal/includes--common.inc/function/format_in... while the others use http://api.drupal.org/api/drupal/includes--common.inc/function/format_da.... In short, it isn't dynamic unless we make it so ourself. That would for example mean an additionalc setting on the privatemsg settings page to choose between interval/date formatting and depending on that, the current our formatting would show up. That seems rather complicated to me.

BenK’s picture

@Berdir: That does sound rather complicated, so I think it's not needed. One option would be to have a "Privatemsg: Current hour" setting that doesn't change from the "time ago" approach. Maybe an option could be either "15 min ago" or "15 minutes ago". This way, a site admin would know that the current hour is formatted differently (and change it a little). But then again, if this is too complicated it is probably not necessary.

Anyway, let's talk soon in IRC! :-)

--Ben

Berdir’s picture

Status: Needs work » Needs review
FileSize
7.22 KB

The "15 mins" comes from format_interval(), we can't add a configuration option for this. Given that we never had a feature request for configurable date formats in years, I don't think many actually care :)

Added options with/without leading zeros and 2/4-digits years. I also updated the defaults values to those without leading zeros. All options are now available for all date formats. Also note that you can always define a custom format in the "Formats" local task which you should be able to use on all date format types.

Status: Needs review » Needs work

The last submitted patch, privatemsg_date_formats2.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
6.5 KB

The test fails are because it is impossible to define "d/m/y" *and* "d/m/Y" as date formats, see #1012620: Unique key on date_formats.(format|type) is problematic for case insensitive collations.

So, new patch without 2/4 digits year selection since that is currently impossible.

Status: Needs review » Needs work

The last submitted patch, privatemsg_date_formats3.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
6.48 KB

Forgot a debug call in there...

BenK’s picture

Status: Needs review » Needs work

Hey Berdir,

Latest patch is working really well. No problems at all. I just have a couple of small things and then this is ready to commit:

A. Given that we have to choose between a two-digit or four-digit year format, I think we should go with the two-digit year format. It's shorter, a bit more common (at least in the U.S.), and that is what Gmail uses.

B. In the format without the leading zeros, we need one more option with the day and month reversed. For instance, for today's date (Jan. 4, 2011), the only available option is:

4/1/11 (I changed the year to two-digit in this example given my comments in A.)

But we also need this option:

1/4/11 (this is the common format in the U.S.)

So that's all I have. With those two changes, this is RTBC and a really nice addition to the module! :-)

--Ben

Berdir’s picture

Status: Needs work » Postponed

A. Ok, changed this. Note that this is only temporary. Once the core bug is fixed, we can add 4-digit years.

B. I actually used that format for the default values, just forgot to add them to the list.

Note that because of the year change, you will have to re-select the correct values (because your currently selected ones are gone). This won't happen for all other who didn't had the patch applied yet.

Commited!

Setting this to postponed so that we can visit it again after the core bug has been resolved.

Berdir’s picture

Status: Postponed » Active

The core issue went in, back to active ;)

ptmkenny’s picture

Assigned: Unassigned » Berdir
Status: Active » Needs work

As per the comments in #11, this still needs just a little work but is almost ready to go.

Berdir’s picture

Assigned: Berdir » Unassigned
Issue tags: +Novice

Another novice issue if someone's interested to pick it up.

Just re-add the different date formats from #6 and this should be good to go.

ExTexan’s picture

Issue summary: View changes

I realize this is an old thread, and the most recent post was 2 years ago, but this is the issue I wanted to discuss.

The date/time formats described in the original post now seem to be the default behavior of the Private Message module. My site visitors are requesting that it show the date/time for all messages regardless of age.

Visitors don't always visit every day, so having messages that are "not in the current day" show only the date doesn't work out so well. Is there a way to configure the date/time display format? Or is there a different patch somewhere that removes the behavior described above and sets it back to showing the full date/time?

ExTexan’s picture

Ahhh, never mind my previous post. I found the date formats and set them to what I wanted. ;-)

ivnish’s picture

Status: Needs work » Closed (outdated)
andypost’s picture

Status: Closed (outdated) » Needs work

D7 is not yet outdated