incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6652] don't use mktime() which assumes time tuple is local time
Date Thu, 12 Sep 2013 14:44:47 GMT
Updated Branches:
  refs/heads/db/6652 [created] 92ff80968


[#6652] don't use mktime() which assumes time tuple is local time


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/92ff8096
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/92ff8096
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/92ff8096

Branch: refs/heads/db/6652
Commit: 92ff80968cd66a94a38da29262f4b54893ad4b69
Parents: 224017c
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Thu Sep 12 14:43:09 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Sep 12 14:43:09 2013 +0000

----------------------------------------------------------------------
 AlluraTest/alluratest/test_syntax.py                | 4 +++-
 ForgeBlog/forgeblog/command/rssfeeds.py             | 4 ++--
 ForgeDiscussion/forgediscussion/controllers/root.py | 5 +++--
 3 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92ff8096/AlluraTest/alluratest/test_syntax.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/test_syntax.py b/AlluraTest/alluratest/test_syntax.py
index b394798..b72052c 100644
--- a/AlluraTest/alluratest/test_syntax.py
+++ b/AlluraTest/alluratest/test_syntax.py
@@ -69,11 +69,13 @@ def test_pyflakes():
     if error:
         raise Exception('pyflakes failure, see stdout')
 
-def test_no_now():
+def test_no_local_tz_functions():
     if run(find_py + " | xargs grep '\.now(' ") not in [1,123]:
         raise Exception("These should use .utcnow()")
     if run(find_py + " | xargs grep '\.fromtimestamp(' ") not in [1,123]:
         raise Exception("These should use .utcfromtimestamp()")
+    if run(find_py + " | xargs grep 'mktime(' ") not in [1,123]:
+        raise Exception("These should use calendar.timegm()")
 
 def test_no_prints():
     skips = [

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92ff8096/ForgeBlog/forgeblog/command/rssfeeds.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/command/rssfeeds.py b/ForgeBlog/forgeblog/command/rssfeeds.py
index 0e70ea9..eeac4b2 100644
--- a/ForgeBlog/forgeblog/command/rssfeeds.py
+++ b/ForgeBlog/forgeblog/command/rssfeeds.py
@@ -15,7 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-from time import mktime
+import calendar
 from datetime import datetime
 import re
 
@@ -128,7 +128,7 @@ class RssFeedsCommand(base.BlogCommand):
                                             getattr(e, 'title'))))
 
         content += u' [link](%s)' % e.link
-        updated = datetime.utcfromtimestamp(mktime(e.updated_parsed))
+        updated = datetime.utcfromtimestamp(calendar.timegm(e.updated_parsed))
 
         base_slug = BM.BlogPost.make_base_slug(title, updated)
         b_count = BM.BlogPost.query.find(dict(slug=base_slug, app_config_id=appid)).count()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/92ff8096/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index c6f9019..aa1130e 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -19,9 +19,10 @@ import json
 import logging
 from urllib import unquote
 from datetime import date, datetime, timedelta, time
-from time import mktime
+import calendar
 from collections import OrderedDict
 
+
 from tg import expose, validate, redirect, flash, response
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from pylons import tmpl_context as c, app_globals as g
@@ -271,7 +272,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
         def reformat_data(mongo_data):
             def item(day, val):
                 return [
-                    mktime(day.timetuple()) * 1000,
+                    calendar.timegm(day.timetuple()) * 1000,
                     val
                 ]
 


Mime
View raw message