From ff513f9efe88138f3356412acca9980599e1bbd4 Mon Sep 17 00:00:00 2001
From: Thierry Carrez <thierry@openstack.org>
Date: Thu, 28 May 2015 15:45:35 +0200
Subject: [PATCH] Add timestamp to the template variables

Add index generation timestamp as a variable available to template
authors ("timestamp").

Change-Id: I7607f0c7eebaad1adca2d6e92a356a3dab1f015b
---
 meetings/example.jinja | 2 ++
 yaml2ical/index.py     | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/meetings/example.jinja b/meetings/example.jinja
index 7c8ecb2..6c4542d 100644
--- a/meetings/example.jinja
+++ b/meetings/example.jinja
@@ -16,3 +16,5 @@ Chair (to contact for more information): {{ meeting.chair }}</p>
 {{ meeting.description|urlize }}
 
 {% endfor %}
+
+<p><i>Page generated on {{ timestamp }} UTC</i></p>
diff --git a/yaml2ical/index.py b/yaml2ical/index.py
index 0fab425..384a2e0 100644
--- a/yaml2ical/index.py
+++ b/yaml2ical/index.py
@@ -10,6 +10,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+import datetime
 import jinja2
 import logging
 import os
@@ -31,6 +32,7 @@ def convert_meetings_to_index(meetings, template, output_file):
     template = env.get_template(template_file)
 
     with open(output_file, "w") as out:
-        out.write(template.render(meetings=meetings))
+        out.write(template.render(meetings=meetings,
+                                  timestamp=datetime.datetime.utcnow()))
 
     logging.info('Wrote %d meetings to index.' % (len(meetings)))