From ca78b94476e4e4d3290317a5a5e22c8549efe2c0 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Mon, 10 Jan 2011 15:48:52 +0000 Subject: [PATCH] NIHVIVO-1591 Modified some comments and names in ftl datetime lib for clarity --- .../templates/freemarker/lib/lib-datetime.ftl | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/webapp/web/templates/freemarker/lib/lib-datetime.ftl b/webapp/web/templates/freemarker/lib/lib-datetime.ftl index 2d3a15bae..f2e2d36ec 100644 --- a/webapp/web/templates/freemarker/lib/lib-datetime.ftl +++ b/webapp/web/templates/freemarker/lib/lib-datetime.ftl @@ -1,21 +1,36 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> -<#-- Macros and functions for datetime formatting --> +<#-- Macros and functions for datetime formatting -<#-- Convenience macros to display year and year interval attributes in a classed span --> + In this library, functions are used to format the datetime or interval + according to a format string and precision, returning a raw string. + Macros are used to generate the string with appropriate markup. +--> + +<#-- MACROS --> + +<#-- Convenience display macros --> <#macro yearSpan dateTime> <#if dateTime?has_content> - ${xsdDateTimeToYear(dateTime)} + <@dateTimeSpan>${xsdDateTimeToYear(dateTime)} <#macro yearIntervalSpan startDateTime endDateTime endYearAsRange=true> <#local yearInterval = yearInterval(startDateTime, endDateTime, endYearAsRange)> <#if yearInterval?has_content> - ${yearInterval} + <@dateTimeSpan>${yearInterval} +<#-- Display the datetime value or interval in a classed span appropriate for + a property statement list --> +<#macro dateTimeSpan> + <#nested> + + + +<#-- FUNCTIONS --> <#-- Assign a year precision and generate the interval --> <#function yearInterval dateTimeStart dateTimeEnd endYearAsRange=true> @@ -34,14 +49,14 @@ <#-- Generate a datetime interval --> -<#function dateTimeInterval dateTimeStart precisionStart dateTimeEnd precisionEnd view="short" endAsRange=true> +<#function dateTimeInterval dateTimeStart precisionStart dateTimeEnd precisionEnd formatType="short" endAsRange=true> <#if dateTimeStart?has_content> - <#local start = formatXsdDateTime(dateTimeStart, precisionStart, view)> + <#local start = formatXsdDateTime(dateTimeStart, precisionStart, formatType)> <#if dateTimeEnd?has_content> - <#local end = formatXsdDateTime(dateTimeEnd, precisionEnd, view)> + <#local end = formatXsdDateTime(dateTimeEnd, precisionEnd, formatType)> <#local interval> @@ -90,22 +105,22 @@ <#return dateTimeString?replace("T", " ")?replace("Z", "")?datetime("yyyy-MM-dd HH:mm:ss")> -<#-- Apply a precision and view to format a datetime --> -<#function formatXsdDateTime dateTime precision view="short"> +<#-- Apply a precision and format type to format a datetime --> +<#function formatXsdDateTime dateTime precision formatType="short"> <#-- First convert the string dateTime to a datetime object --> <#local dt = toDateTime(dateTime)> <#-- Use the precision to determine which portion to display, - and the view to determine how to display it. --> + and the format type to determine how to display it. --> <#local format> - <#if view == "long"> + <#if formatType == "long"> <#if precision == "yearPrecision">yyyy <#elseif precision == "yearMonthPrecision">MMMM yyyy <#elseif precision == "yearMonthDayPrecision">MMMM d, yyyy <#else>MMMM d, yyyy h:mm a - <#else> <#-- view == "short" --> + <#else> <#-- formatType == "short" --> <#if precision == "yearPrecision">yyyy <#elseif precision == "yearMonthPrecision">M/yyyy <#elseif precision == "yearMonthDayPrecision">M/d/yyyy