New function - getMeridiem

November 02, 2012

I just submitted a function to CFLib.org and thought I'd post it here too. getMeridiem() isn't super fancy, it just returns the "AM/PM" portion of a datetime (the name of which is the "meridiem"). As you can see, you can get that information from the built-in function TimeFormat(). All I'm doing is adding a little extra whitespace housecleaning and validation (which is useful if the dates might be badly formed...a situation I ran into last week...hence my writing this function). Also, I find getMeridiem() is a more intuitive name and it's more clear what that function does than TimeFormat( theTime, "tt" )...self documenting code and all that.

The source code and examples look like so: Examples:
<cfoutput>
#getMeridiem( "4/2/2012 14:33:00" )#
#getMeridiem( "14:33:00" )#
#getMeridiem( CreateTime( 17, 30, 00 ) )#
</cfoutput>

Feel free to add this to your own Date/Time libraries for later use. Feedback is welcome.

-nolan