Erikhht / gaewiki

Automatically exported from code.google.com/p/gaewiki
0 stars 0 forks source link

add timezone support #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
http://pytz.sourceforge.net/

diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/filters.py gaewiki/gaewiki/filters.py
--- gaewiki.orig/gaewiki/filters.py 2011-07-25 02:41:56 +0900
+++ gaewiki/gaewiki/filters.py  2011-12-01 03:08:06 +0900
@@ -4,8 +4,10 @@
 use_library('django', '0.96')
 from google.appengine.ext.webapp import template

+import settings
 import util

+import pytz

 register = template.create_template_register()

@@ -58,3 +60,12 @@
 @register.filter
 def cleanup_summary(text):
     return util.cleanup_summary(text)
+
+
+@register.filter
+def timezone(date, tz=None):
+    if not tz:
+        tz = settings.get('timezone')
+    if tz:
+        return date.replace(tzinfo=pytz.UTC).astimezone(pytz.timezone(tz))
+    return date
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/settings.py gaewiki/gaewiki/settings.py
--- gaewiki.orig/gaewiki/settings.py    2011-05-14 18:57:32 +0900
+++ gaewiki/gaewiki/settings.py 2011-12-01 03:09:22 +0900
@@ -18,6 +18,7 @@
 editors: user1@example.com, user2@example.com
 interwiki-google: http://www.google.ru/search?q=%s
 interwiki-wp: http://en.wikipedia.org/wiki/Special:Search?search=%s
+timezone: UTC
 ---
 # gaewiki:settings

diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/base.html gaewiki/gaewiki/templates/base.html
--- gaewiki.orig/gaewiki/templates/base.html    2011-06-03 03:03:20 +0900
+++ gaewiki/gaewiki/templates/base.html 2011-12-01 02:59:51 +0900
@@ -66,7 +66,7 @@
        {% block footer %}
       <div id="footer">
         {% if page.is_saved %}
-        <p id="pm">This page was last edited {% if page.author.get_nickname 
%}by <a href="/user%3A{{ page.author.get_nickname|uurlencode }}">{{ 
page.author.get_nickname|escape }}</a>{% else %}anonymously{% endif %} on {{ 
page.updated|date:"d.m.y" }} at {{ page.updated|date:"H:i" }}.</p>
+        <p id="pm">This page was last edited {% if page.author.get_nickname 
%}by <a href="/user%3A{{ page.author.get_nickname|uurlencode }}">{{ 
page.author.get_nickname|escape }}</a>{% else %}anonymously{% endif %} on {{ 
page.updated|timezone|date:"Y/m/d H:i:s" }}.</p>
         {% endif %}
         {% if footer %}{{ footer|wikify }}{% endif %}
       </div>
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/changes.html 
gaewiki/gaewiki/templates/changes.html
--- gaewiki.orig/gaewiki/templates/changes.html 2011-06-03 03:39:36 +0900
+++ gaewiki/gaewiki/templates/changes.html  2011-12-01 03:01:27 +0900
@@ -25,7 +25,7 @@
           <a class="int{% if page.pread %} public{% endif %}" href="{{ page.title|pageurl }}">{{ page.title|escape }}</a>
         </td>
         <td>
-          {{ page.updated|date:"d.m.y, H:i" }}
+          {{ page.updated|timezone|date:"Y/m/d H:i:s" }}
         </td>
         <td>
           {% if page.author %}
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/changes.rss gaewiki/gaewiki/templates/changes.rss
--- gaewiki.orig/gaewiki/templates/changes.rss  2011-06-03 03:38:14 +0900
+++ gaewiki/gaewiki/templates/changes.rss   2011-12-01 03:01:40 +0900
@@ -10,7 +10,7 @@
 <title>{{ page.get_display_title|escape }}</title>
 <link>{{ base }}{{ page.title|pageurl }}</link>
 <guid>{{ base }}{{ page.title|pageurl }}</guid>
-<pubDate>{{ page.created|date:"r" }}</pubDate>
+<pubDate>{{ page.created|timezone|date:"r" }}</pubDate>
 <author>{{ page.author.get_public_email|escape }}</author>
 </item>
 {% endfor %}
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/history.html 
gaewiki/gaewiki/templates/history.html
--- gaewiki.orig/gaewiki/templates/history.html 2011-05-01 04:08:10 +0900
+++ gaewiki/gaewiki/templates/history.html  2011-12-01 03:01:52 +0900
@@ -12,7 +12,7 @@
 {% if revisions %}
   <p>The following revisions are available:</p>
   <ul>{% for revision in revisions %}
-    <li><a class="int" href="{{ page_title|pageurl }}?r={{ revision.key 
}}">Revision from {{ revision.created|date:"d.m.y, H:i"}}</a></li>
+    <li><a class="int" href="{{ page_title|pageurl }}?r={{ revision.key 
}}">Revision from {{ revision.created|timezone|date:"Y/m/d H:i:s"}}</a></li>
   {% endfor %}</ul>
 {% else %}
 <p>We have no records for this page.</p>
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/index.rss gaewiki/gaewiki/templates/index.rss
--- gaewiki.orig/gaewiki/templates/index.rss    2011-06-25 01:40:54 +0900
+++ gaewiki/gaewiki/templates/index.rss 2011-12-01 03:02:17 +0900
@@ -14,7 +14,7 @@
 <title>{{ item.get_display_title|escape }}</title>
 <link>{{ base }}{{ item.title|pageurl }}</link>
 <guid>{{ base }}{{ item.title|pageurl }}</guid>
-<pubDate>{{ item.updated|date:"r" }}</pubDate>
+<pubDate>{{ item.updated|timezone|date:"r" }}</pubDate>
 <author>{{ item.author.get_public_email|escape }}</author>
 <description>{{ item.body|wikify|escape }}</description>
 {% if item.get_file %}
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/sitemap.xml gaewiki/gaewiki/templates/sitemap.xml
--- gaewiki.orig/gaewiki/templates/sitemap.xml  2011-06-03 03:26:50 +0900
+++ gaewiki/gaewiki/templates/sitemap.xml   2011-12-01 03:02:26 +0900
@@ -2,7 +2,7 @@
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 {% for page in pages %}<url>
 <loc>{{ base }}{{ page.title|pageurl }}</loc>
-{% if page.updated %}<lastmod>{{ page.updated|date:"Y-m-d" }}</lastmod>
+{% if page.updated %}<lastmod>{{ page.updated|timezone|date:"Y-m-d" 
}}</lastmod>
 {% endif %}</url>
 {% endfor %}
 </urlset>
diff -urN -x '*.yaml' -x '*.bat' -x '*.pyc' -x pytz 
gaewiki.orig/gaewiki/templates/users.html gaewiki/gaewiki/templates/users.html
--- gaewiki.orig/gaewiki/templates/users.html   2011-06-03 03:03:18 +0900
+++ gaewiki/gaewiki/templates/users.html    2011-12-01 03:02:35 +0900
@@ -15,7 +15,7 @@
       {% for user in users %}
         <tr>
           <td><a href="/user%3A{{ user.get_nickname|uurlencode }}">{{ user.get_nickname|escape }}</a></td>
-          <td>{{ user.joined|date:"Y-m-d" }}</td>
+          <td>{{ user.joined|timezone|date:"Y-m-d" }}</td>
         </tr>
       {% endfor %}
       </tbody>

Original issue reported on code.google.com by h.rayflood on 30 Nov 2011 at 6:13

GoogleCodeExporter commented 9 years ago

Original comment by justin.forest on 30 Nov 2011 at 7:40

GoogleCodeExporter commented 9 years ago
This issue was closed by revision ff442af8e8c5.

Original comment by justin.forest on 30 Nov 2011 at 8:43

GoogleCodeExporter commented 9 years ago
Thank you very much.

Original comment by justin.forest on 30 Nov 2011 at 8:43

GoogleCodeExporter commented 9 years ago
This issue was updated by revision e9407575045d.

Updated date format in templates.

Original comment by justin.forest on 1 Dec 2011 at 8:40