]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/output/template/Template.java
upd: restrict permissions of org "master" admin on organisation
[gigi.git] / src / org / cacert / gigi / output / template / Template.java
index d49df9ae2c5a4c8600a0f48e631b1ed9caf91f0b..858b04806bcbe9e2591682492f1512936f6472f3 100644 (file)
@@ -9,17 +9,20 @@ import java.io.PrintWriter;
 import java.io.Reader;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.cacert.gigi.localisation.Language;
+import org.cacert.gigi.output.DateSelector;
 import org.cacert.gigi.util.HTMLEncoder;
 
 public class Template implements Outputable {
 
-    class ParseResult {
+    private static class ParseResult {
 
         TemplateBlock block;
 
@@ -54,7 +57,7 @@ public class Template implements Outputable {
 
     private File source;
 
-    private static final Pattern CONTROL_PATTERN = Pattern.compile(" ?([a-z]+)\\(\\$([^)]+)\\) ?\\{ ?");
+    private static final Pattern CONTROL_PATTERN = Pattern.compile(" ?([a-zA-Z]+)\\(\\$([^)]+)\\) ?\\{ ?");
 
     private static final Pattern ELSE_PATTERN = Pattern.compile(" ?\\} ?else ?\\{ ?");
 
@@ -187,6 +190,12 @@ public class Template implements Outputable {
         }
         if (s instanceof Outputable) {
             ((Outputable) s).output(out, l, vars);
+        } else if (s instanceof java.sql.Date) {
+            out.print(DateSelector.getDateFormat().format(s));
+        } else if (s instanceof Date) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            out.print(sdf.format(s));
+            out.print(" UTC");
         } else {
             out.print(s == null ? "null" : (unescaped ? s.toString() : HTMLEncoder.encodeHTML(s.toString())));
         }