summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-02-19 23:38:55 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-02-19 23:38:55 +1100
commit5d06fecfb70f0e32fe670775cc02682e61bf81d6 (patch)
tree1704da9d5e46ebc887f9c2987799baf6387b19fc
parent6f124fdbccc89a53972c1888cc7c0dbb19c402f1 (diff)
specify timezone in <time> datetime attribute
-rw-r--r--inc/contrib/Twig/Extensions/Extension/Tinyboard.php6
-rw-r--r--templates/post_reply.html2
-rw-r--r--templates/post_thread.html2
3 files changed, 8 insertions, 2 deletions
diff --git a/inc/contrib/Twig/Extensions/Extension/Tinyboard.php b/inc/contrib/Twig/Extensions/Extension/Tinyboard.php
index 5c6621f6..0cf7705a 100644
--- a/inc/contrib/Twig/Extensions/Extension/Tinyboard.php
+++ b/inc/contrib/Twig/Extensions/Extension/Tinyboard.php
@@ -34,6 +34,7 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
{
return Array(
'time' => new Twig_Filter_Function('time', array('needs_environment' => false)),
+ 'timezone' => new Twig_Filter_Function('twig_timezone_function', array('needs_environment' => false)),
'createHiddenInputs' => new Twig_Filter_Function('createHiddenInputs', array('needs_environment' => false))
);
}
@@ -49,6 +50,11 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
}
}
+function twig_timezone_function() {
+ // there's probably a much easier way of doing this
+ return sprintf("%s%02d", ($hr = (int)floor(($tz = date('Z')) / 3600)) > 0 ? '+' : '-', abs($hr)) . ':' . sprintf("%02d", (($tz / 3600) - $hr) * 60);
+}
+
function twig_remove_whitespace_filter($data) {
return preg_replace('/[\t\r\n]/', '', $data);
}
diff --git a/templates/post_reply.html b/templates/post_reply.html
index 687040f6..0aacd015 100644
--- a/templates/post_reply.html
+++ b/templates/post_reply.html
@@ -28,7 +28,7 @@
{% if post.mod and post.mod|hasPermission(config.mod.show_ip, board.uri) %}
[<a style="margin:0;" href="?/IP/{{ post.ip }}">{{ post.ip }}</a>]
{% endif %}
- <time datetime="{{ post.time|date('%Y-%m-%dT%H:%M:%S') }}">{{ post.time|date(config.post_date) }}</time>
+ <time datetime="{{ post.time|date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}">{{ post.time|date(config.post_date) }}</time>
</label>
{% if config.poster_ids %}
ID: {{ post.ip|poster_id(post.thread) }}
diff --git a/templates/post_thread.html b/templates/post_thread.html
index 2bc2a7ce..58386e6e 100644
--- a/templates/post_thread.html
+++ b/templates/post_thread.html
@@ -73,7 +73,7 @@
{% if post.mod and post.mod|hasPermission(config.mod.show_ip, board.uri) %}
[<a style="margin:0;" href="?/IP/{{ post.ip }}">{{ post.ip }}</a>]
{% endif %}
- <time datetime="{{ post.time|date('%Y-%m-%dT%H:%M:%S') }}">{{ post.time|date(config.post_date) }}</time>
+ <time datetime="{{ post.time|date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}">{{ post.time|date(config.post_date) }}</time>
</label>
{% if config.poster_ids %}
ID: {{ post.ip|poster_id(post.id) }}