[Mpuls-commits] r3108 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 2 11:02:49 CEST 2010


Author: roland
Date: 2010-07-02 11:02:47 +0200 (Fri, 02 Jul 2010)
New Revision: 3108

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/helpers.py
Log:
Show rounded up time for session expiring, without seconds

Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-07-02 06:31:00 UTC (rev 3107)
+++ base/trunk/ChangeLog	2010-07-02 09:02:47 UTC (rev 3108)
@@ -1,3 +1,8 @@
+2010-07-02 Roland Geider <roland.geider at intevation.de>
+
+	* mpulsweb/lib/helpers.py: Round up the time the session ends
+	  to the nearest 5 min. Also, don't show the seconds.
+
 2010-06-30  Bernhard Herzog  <bh at intevation.de>
 
 	* development.ini: Add logging configuration for an optional

Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2010-07-02 06:31:00 UTC (rev 3107)
+++ base/trunk/mpulsweb/lib/helpers.py	2010-07-02 09:02:47 UTC (rev 3108)
@@ -143,7 +143,7 @@
     """
     timeout = int(config.get("beaker.session.timeout"))
     return format_time(datetime.datetime.now()
-                       + datetime.timedelta(seconds=timeout - 120))
+                       + datetime.timedelta(seconds=timeout - 120), True)
 
 def getHelp(help_id):
     '''
@@ -232,12 +232,18 @@
         log.error(err)
         return dd_mm_YYYY(dt)
 
-def format_time(dt):
+def format_time(dt, approximate=False):
+    """
+    Format time with the correct locale. If the optional parameter "approximate"
+    is set, the minutes will be rounded to the next multiple of 5
+    """
     if dt is None:
         return ''
     try:
         cs = locale.nl_langinfo(locale.CODESET)
-        return unicode(dt.strftime(locale.nl_langinfo(locale.T_FMT)), cs)
+        if approximate:
+            dt = dt.replace(minute = int(5 * round(float(dt.minute)/5)))
+        return unicode(dt.strftime('%H:%M'), cs)
     except Exception, err:
         log.error(err)
         return ''



More information about the Mpuls-commits mailing list