From 28a2be38bc221b5bb009791c61d71d0d6615e3c9 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Thu, 6 Jan 2011 21:19:42 +0000 Subject: [PATCH] NIHVIVO-1610 Extracted datetime code in propStatement templates into a macro. --- .../templates/freemarker/lib/lib-datetime.ftl | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/webapp/web/templates/freemarker/lib/lib-datetime.ftl b/webapp/web/templates/freemarker/lib/lib-datetime.ftl index 994b7bfb8..a82c92f91 100644 --- a/webapp/web/templates/freemarker/lib/lib-datetime.ftl +++ b/webapp/web/templates/freemarker/lib/lib-datetime.ftl @@ -8,6 +8,37 @@ but not data extraction. --> +<#-- Macro yearInterval + + Display a year interval in a property statement + + Set endYearAsRange=false to display an end year without a start year without a preceding hyphen. The hyphen indicates that + a range is expected but the start year is not provided (e.g., core:personInPosition); no hyphen indicates that + a single date is typical (e.g., core:educationalTraining). +--> + +<#macro yearInterval startDateTime endDateTime endYearAsRange=true> + <#local yearInterval> + <#if startDateTime?has_content> + <#local startYear = xsdDateTimeToYear(startDateTime)> + + <#if endDateTime?has_content> + <#local endYear = xsdDateTimeToYear(endDateTime)> + + <#if startYear?? && endYear??> + ${startYear} - ${endYear} + <#elseif startYear??> + ${startYear} - + <#elseif endYear ??> + <#if endYearAsRange>- ${endYear} + + + + <#if yearInterval?has_content> + ${yearInterval} + + + <#-- Function xsdDateTimeToYear Display an XSD datetime string as a year. @@ -17,4 +48,6 @@ <#function xsdDateTimeToYear datetime> <#return datetime?date("yyyy")?string("yyyy") > - \ No newline at end of file + + +