diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java index 1cfc876c6..73657df64 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java @@ -114,7 +114,7 @@ public class FreemarkerConfigurationLoader { String dateFormat = "M/d/yyyy"; config.setDateFormat(dateFormat); - String timeFormat = "hh:mm a"; + String timeFormat = "h:mm a"; config.setTimeFormat(timeFormat); config.setDateTimeFormat(dateFormat + " " + timeFormat); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java index 0a7b7251c..dc4835cf2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java @@ -256,13 +256,13 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec */ public List> getObjectPropertyStatementsForIndividualByProperty(String subjectUri, String propertyUri, String queryString) { - log.debug("Object property query string: " + queryString); + log.debug("Query string for object property " + propertyUri + ": " + queryString); Query query = null; try { query = QueryFactory.create(queryString, Syntax.syntaxARQ); } catch(Throwable th){ - log.error("could not create SPARQL query for query string " + th.getMessage()); + log.error("Could not create SPARQL query for query string. " + th.getMessage()); log.error(queryString); } @@ -280,7 +280,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec QueryExecution qexec = QueryExecutionFactory.create( query, dataset, bindings); ResultSet results = qexec.execSelect(); - + while (results.hasNext()) { QuerySolution soln = results.nextSolution(); list.add(QueryUtils.querySolutionToStringValueMap(soln)); diff --git a/webapp/web/templates/freemarker/lib/lib-datetime.ftl b/webapp/web/templates/freemarker/lib/lib-datetime.ftl index a82c92f91..bb8e4576c 100644 --- a/webapp/web/templates/freemarker/lib/lib-datetime.ftl +++ b/webapp/web/templates/freemarker/lib/lib-datetime.ftl @@ -1,12 +1,6 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> -<#-- Macros and functions for datetime formatting. - - Currently these do more than format the datetime string, they actually select the precision as well. This should change in a future - implementation; see NIHVIVO-1567. We want the Java code to apply the precision to the datetime string to pass only the - meaningful data to the templates. The templates can format as they like, so these functions/macros would do display formatting - but not data extraction. - --> +<#-- Macros for datetime formatting --> <#-- Macro yearInterval @@ -39,15 +33,77 @@ -<#-- Function xsdDateTimeToYear - - Display an XSD datetime string as a year. - - Example: 1983-12-07T17:15:28Z displays as 1983 +<#macro dateTimeInterval dateTimeStart precisionStart dateTimeEnd precisionEnd endAsRange=true> + + <#if dateTimeStart?has_content> + <#local start = formatXsdDateTime(dateTimeStart, precisionStart)> + + + <#if dateTimeEnd?has_content> + <#local end = formatXsdDateTime(dateTimeEnd, precisionEnd)> + + + <#local interval> + <#if start?? && end??> + ${start} - ${end} + <#elseif start??> + ${start} - + <#elseif end??> + <#if endAsRange>- ${end} + + + + <#if interval?has_content> + ${interval} + + + +<#-- Functions for formatting and applying precision to a datetime + + Currently these do more than format the datetime string, they select the precision as well. This should change in a future + implementation; see NIHVIVO-1567. We want the Java code to apply the precision to the datetime string to pass only the + meaningful data to the templates. The templates can format as they like, so these functions/macros would do display formatting + but not data extraction. --> -<#function xsdDateTimeToYear datetime> - <#return datetime?date("yyyy")?string("yyyy") > +<#function toDateTime dateTimeString> + <#-- First convert the datetime string to a string format that Freemarker + understands, then to a datetime object --> + <#return dateTimeString?replace("T", " ")?datetime("yyyy-MM-dd HH:mm:ss")> +<#function formatXsdDateTime dateTime precision view="short"> + <#-- Convert to a string format that Freemarker understands, + then to a datetime --> + <#local dt = toDateTime(dateTime)> + + <#-- Use the precision to determine which portion to display, + and the view to determine how to display it. --> + <#local format> + <#if view == "long"> + <#if precision == "yearPrecision">yyyy + <#elseif precision == "yearMonthPrecision">MMMM yyyy + <#elseif precision == "yearMonthDayPrecision">MMMM d, yyyy + <#else>MMMM d, yyyy h:mm a + + <#else> + <#if precision == "yearPrecision">yyyy + <#elseif precision == "yearMonthPrecision">M-yyyy + <#elseif precision == "yearMonthDayPrecision">M-d-yyyy + <#else>M-d-yyyy h:mm a + + + + + <#return dt?string(format)> + + +<#-- Function xsdDateTimeToYear --> + +<#-- get rid of this --> + +<#function xsdDateTimeToYear datetime> + <#local format = "yyyy"> + <#return datetime?date(format)?string(format)> +