Expert Date Formatter in use on Proctors.org

Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Expert Date is a display field formatter for Date fields that hides and shows parts of the date string to save you from writing a massive switch/case statement in your code. Each of the options is independent of the others, and there are many semantic features developed over years of practical use.

Set up the module in Content Types > Display Fields area or your Views where you would normally apply a Date formatter. You may choose zero or all of the options for each instance of the field.

Expert date does not create new Date Types, you are expected to create those based on your preference using the Regional and Language > Date and Time section of Drupal Core. Once you create a Date Type that contains all the components you want, this formatter removes extra occurrences of date parts from the output. You may also use the built-in Long, Medium, and Short Date Types if you wish.

This module does not change the metadata, it augments the given date format string based on the current start and end dates, the current year, and other factors.

Examples of Expert Date in use
option
before after
Time Range

Hide time if the start and end dates are a not the same

Thursday, October 9, 2014, 11:30 am to Friday, October 10, 2014, 12:30 pm Thursday, October 9, 2014 to Friday, October 10, 2014
Weekday Range

Hide weekday (Sunday, Monday) if start and end dates are not the same

Thursday, October 9, 2014, 11:30 am to Friday, October 10, 2014, 12:30 pm October 9, 2014, 11:30 am to October 10, 2014, 12:30 pm
Day Range

Hide the end date if the start and end dates are the same

Thursday, October 9, 2014, 11:30 am to Thursday, October 9, 2014, 12:30 pm Thursday, October 9, 2014, 11:30 am
Month Range

Hide month if start and end date are in the same month

Thursday, October 9, 2014, 11:30 am to Friday, October 10, 2014, 12:30 pm Thursday, October 9, 2014, 11:30 am to Friday, 10, 2014, 12:30 pm
Year Range

Hide year if end date is the same as the current year

Thursday, October 9, 2014, 11:30 am to Friday, October 10, 2014, 12:30 pm Thursday, October 9, 11:30 am to Friday, October 10, 12:30 pm
All of the above
Thursday, October 9, 2014, 11:30 am to Friday, October 10, 2014, 12:30 pm October 9 to 10
Time Field

Hide the time if a specified field has more than one value (plus "Day Range")

Thursday, October 9, 2014, 11:30 am to Thursday, October 9, 2014, 9:30 pm Thursday, October 9, 2014
All of the above
Thursday, October 9, 2014, 11:30 am to Thursday, October 9, 2014, 9:30 pm Thursday, October 9

The "Time Field" can be useful in a performing arts context, if one "Event" has multiple "Performances" or "Showings" on the same day, but you are not displaying each individual occurrence.

Time Field Example: Events that happen a few times vs. every day

Proctors has Events that come for one night or one week, but they also have Events that are Educational films. The films show multiple times per day, every day.

In this case, there is one "Event" for the Film, and a Field Collection for individual showtimes and Buy buttons. This would also work with an Entityreference field, Commerce Product Reference field, or any multi-value field. Since this formatter is configurable per Views display, you may still show more detailed listings elsewhere on your site.

Development sponsored by Proctors

Project information