changeset 883:a170df39355f

@SIG@ etc. generate local time stamps now, no difference visible on page view. Thanks to anarcat.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Thu, 06 Jul 2006 18:09:34 +0200
parents e2c03a3c79d6
children 51eae6ce2be7 203686df2c6d
files MoinMoin/PageEditor.py docs/CHANGES
diffstat 2 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Thu Jul 06 16:42:41 2006 +0200
+++ b/MoinMoin/PageEditor.py	Thu Jul 06 18:09:34 2006 +0200
@@ -629,6 +629,34 @@
         # No mail sent, no message.
         return ''
 
+    def _get_local_timestamp(self):
+        """
+        Returns the string that can be used by the TIME substitution.
+
+        @return: str with a timestamp in it
+        """
+
+        now = time.time()
+        # default: UTC
+        zone = "Z"
+        user = self.request.user
+
+        # setup the timezone
+        if user.valid and user.tz_offset:
+            tz = user.tz_offset
+            # round to minutes
+            tz -= tz % 60
+            minutes = tz / 60
+            hours = minutes / 60
+            minutes -= hours * 60
+
+            # construct the offset
+            zone = "%+0.2d%02d" % (hours, minutes)
+            # correct the time by the offset we've found
+            now += tz
+
+        return time.strftime("%Y-%m-%dT%H:%M:%S", timefuncs.tmtuple(now)) + zone
+
     def _expand_variables(self, text):
         """
         Expand @VARIABLE@ in `text`and return the expanded text.
@@ -639,7 +667,7 @@
         """
         # TODO: Allow addition of variables via wikiconfig or a global
         # wiki dict.
-        now = time.strftime("%Y-%m-%dT%H:%M:%SZ", timefuncs.tmtuple())
+        now = self._get_local_timestamp()
         user = self.request.user
         signature = user.signature()
         variables = {
--- a/docs/CHANGES	Thu Jul 06 16:42:41 2006 +0200
+++ b/docs/CHANGES	Thu Jul 06 18:09:34 2006 +0200
@@ -156,6 +156,8 @@
       engines don't fetch the targets (if they do, they will just get 403 and
       cause unnecessary traffic).
     * Included EmbedObject macro for embedding shockwave flash, mp3, visio, ...
+    * @SIG@ etc. generate local time stamps now, no difference visible on page
+      view.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page