Fix date/time presentation in activity chart.

portnov [2008-06-13 07:49:19]
Fix date/time presentation in activity chart.
Filename
pygit/pygit.py
settings.py
diff --git a/pygit/pygit.py b/pygit/pygit.py
index f1d63a4..99fc512 100644
--- a/pygit/pygit.py
+++ b/pygit/pygit.py
@@ -1,10 +1,9 @@

 from os.path import basename,dirname,exists
+import time
 import gzip
 from git import *

-# sys.path.append(dirname(dirname(__file__)))
-# from settings import REPOS
 from django.conf import settings

 rp = None
@@ -43,8 +42,8 @@ def tags(rid):
   return [t.name for t in r.tags]

 def date(tp):
-  y,m,d,h,M,s,_,_,_ = tp
-  return "%d.%d.%d %d:%d:%d" % (d,m,y,h,M,s)
+  dt = time.localtime(time.mktime(tp)-time.altzone)
+  return time.strftime("%d.%m.%Y %H:%M:%S", dt)

 def tarball(rid,branch):
   r = open_repo(rid)
@@ -109,9 +108,9 @@ def diff_path(rid,path,cid1,cid2=None):
 def group_by_date(lst):
   "[Commit] -> [(date,Commit)]"
   def date(tp):
-    y,m,d = tp
-    return "%d.%d" % (d,m)
-  d = [(c.authored_date[:3], c) for c in lst]
+    dt = time.localtime(time.mktime(tp)-time.altzone)
+    return time.strftime("%d.%m", dt)
+  d = [(c.authored_date, c) for c in lst]
   d.sort()
   d = [(date(e[0]),e[1]) for e in d]
   prev = d[0][0]
@@ -125,7 +124,7 @@ def group_by_date(lst):
       del group
       group = []
     prev = dt
-#   r.append((prev,group))
+  r.append((prev,group))
   return r

 def stats_sum(lst):
@@ -143,6 +142,7 @@ def commits_stats(rid,branch='master'):
   r = open_repo(rid)
   d = r.commits(branch,max_count=200)
   grp = group_by_date(d)
+  print [(g[0],[c.message for c in g[1]]) for g in grp]
   dates = [g[0] for g in grp]
   n_commits = [len(g[1]) for g in grp]
   stats = [stats_sum(g[1]) for g in grp]
diff --git a/settings.py b/settings.py
index 49e3966..847ccab 100644
--- a/settings.py
+++ b/settings.py
@@ -20,7 +20,7 @@ DATABASE_PORT = ''             # Set to empty string for default. Not used with

 # Local time zone for this installation. All choices can be found here:
 # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-TIME_ZONE = 'America/Chicago'
+TIME_ZONE = 'Asia/Yekaterinburg'

 # Language code for this installation. All choices can be found here:
 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
ViewGit