2011
So today I got a call from one of my clients. The app we built for her is an event management app, and one of its functions outputs a list of all the events, including the start and ending times for each event. Those times are output using ColdFusion's TimeFormat() function like so:
#TimeFormat(event.startTime,"h:mm tt")# - #TImeFormat(event.endTime,"h:mm tt")#
...which (for example) comes out as:
10:00 AM - 1:30 PM
My client was calling because she was told (by the local style enforcer, I guess) that the university's publishing style dictates dropping the ":00" for times that start on the hour and to use "a.m." and "p.m." rather than "AM" or "PM". She wanted to know if I could adjust the report output to meet the style.
I briefly tried to see if there was a way to change the mask parameters in TimeFormat() to get the desired format, with no luck. A quick search online for a ready-made solution also didn't yield any results. So I ended up doing this:
<cfset initialVals= "AM,PM,:00"> <cfset newVals= "a.m.,p.m.,"> ... #ReplaceList(TimeFormat(event.startTime,"h:mm tt"),initialVals,newVals)# - #ReplaceLIst(TimeFormat(event.endTime,"h:mm tt"),initialVals,newVals)#
That did the trick, but if someone's got another way of handling it, please feel free to share.
Recent Comments