##// END OF EJS Templates
vcs: make commit datetimes utc
dan -
r154:3953c69f default
parent child Browse files
Show More
@@ -35,7 +35,7 b' def makedate():'
35 return time.mktime(lt), tz
35 return time.mktime(lt), tz
36
36
37
37
38 def date_fromtimestamp(unixts, tzoffset=0):
38 def utcdate_fromtimestamp(unixts, tzoffset=0):
39 """
39 """
40 Makes a local datetime object out of unix timestamp
40 Makes a local datetime object out of unix timestamp
41
41
@@ -43,7 +43,7 b' def date_fromtimestamp(unixts, tzoffset='
43 :param tzoffset:
43 :param tzoffset:
44 """
44 """
45
45
46 return datetime.datetime.fromtimestamp(float(unixts))
46 return datetime.datetime.utcfromtimestamp(float(unixts))
47
47
48
48
49 def date_astimestamp(value):
49 def date_astimestamp(value):
@@ -30,7 +30,7 b' from StringIO import StringIO'
30
30
31 from zope.cachedescriptors.property import Lazy as LazyProperty
31 from zope.cachedescriptors.property import Lazy as LazyProperty
32
32
33 from rhodecode.lib.datelib import date_fromtimestamp
33 from rhodecode.lib.datelib import utcdate_fromtimestamp
34 from rhodecode.lib.utils import safe_unicode, safe_str
34 from rhodecode.lib.utils import safe_unicode, safe_str
35 from rhodecode.lib.utils2 import safe_int
35 from rhodecode.lib.utils2 import safe_int
36 from rhodecode.lib.vcs.conf import settings
36 from rhodecode.lib.vcs.conf import settings
@@ -95,7 +95,7 b' class GitCommit(base.BaseCommit):'
95 if value:
95 if value:
96 value = safe_unicode(value)
96 value = safe_unicode(value)
97 elif attr == "date":
97 elif attr == "date":
98 value = date_fromtimestamp(*value)
98 value = utcdate_fromtimestamp(*value)
99 elif attr == "parents":
99 elif attr == "parents":
100 value = self._make_commits(value)
100 value = self._make_commits(value)
101 self.__dict__[attr] = value
101 self.__dict__[attr] = value
@@ -135,7 +135,7 b' class GitCommit(base.BaseCommit):'
135 def date(self):
135 def date(self):
136 unix_ts, tz = self._remote.get_object_attrs(
136 unix_ts, tz = self._remote.get_object_attrs(
137 self.raw_id, self._date_property, self._date_tz_property)
137 self.raw_id, self._date_property, self._date_tz_property)
138 return date_fromtimestamp(unix_ts, tz)
138 return utcdate_fromtimestamp(unix_ts, tz)
139
139
140 @LazyProperty
140 @LazyProperty
141 def status(self):
141 def status(self):
@@ -31,7 +31,7 b' import time'
31 from zope.cachedescriptors.property import Lazy as LazyProperty
31 from zope.cachedescriptors.property import Lazy as LazyProperty
32
32
33 from rhodecode.lib.compat import OrderedDict
33 from rhodecode.lib.compat import OrderedDict
34 from rhodecode.lib.datelib import makedate, date_fromtimestamp
34 from rhodecode.lib.datelib import makedate, utcdate_fromtimestamp
35 from rhodecode.lib.utils import safe_unicode, safe_str
35 from rhodecode.lib.utils import safe_unicode, safe_str
36 from rhodecode.lib.vcs import connection, path as vcspath
36 from rhodecode.lib.vcs import connection, path as vcspath
37 from rhodecode.lib.vcs.backends.base import (
37 from rhodecode.lib.vcs.backends.base import (
@@ -269,7 +269,7 b' class GitRepository(BaseRepository):'
269 Returns last change made on this repository as
269 Returns last change made on this repository as
270 `datetime.datetime` object.
270 `datetime.datetime` object.
271 """
271 """
272 return date_fromtimestamp(self._get_mtime(), makedate()[1])
272 return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
273
273
274 def _get_mtime(self):
274 def _get_mtime(self):
275 try:
275 try:
@@ -26,7 +26,7 b' import os'
26
26
27 from zope.cachedescriptors.property import Lazy as LazyProperty
27 from zope.cachedescriptors.property import Lazy as LazyProperty
28
28
29 from rhodecode.lib.datelib import date_fromtimestamp
29 from rhodecode.lib.datelib import utcdate_fromtimestamp
30 from rhodecode.lib.utils import safe_str, safe_unicode
30 from rhodecode.lib.utils import safe_str, safe_unicode
31 from rhodecode.lib.vcs import path as vcspath
31 from rhodecode.lib.vcs import path as vcspath
32 from rhodecode.lib.vcs.backends import base
32 from rhodecode.lib.vcs.backends import base
@@ -78,7 +78,7 b' class MercurialCommit(base.BaseCommit):'
78 elif attr == "affected_files":
78 elif attr == "affected_files":
79 value = map(safe_unicode, value)
79 value = map(safe_unicode, value)
80 elif attr == "date":
80 elif attr == "date":
81 value = date_fromtimestamp(*value)
81 value = utcdate_fromtimestamp(*value)
82 elif attr in ["children", "parents"]:
82 elif attr in ["children", "parents"]:
83 value = self._make_commits(value)
83 value = self._make_commits(value)
84 self.__dict__[attr] = value
84 self.__dict__[attr] = value
@@ -114,7 +114,7 b' class MercurialCommit(base.BaseCommit):'
114
114
115 @LazyProperty
115 @LazyProperty
116 def date(self):
116 def date(self):
117 return date_fromtimestamp(*self._remote.ctx_date(self.idx))
117 return utcdate_fromtimestamp(*self._remote.ctx_date(self.idx))
118
118
119 @LazyProperty
119 @LazyProperty
120 def status(self):
120 def status(self):
@@ -33,8 +33,7 b' from zope.cachedescriptors.property impo'
33
33
34 from rhodecode.lib.compat import OrderedDict
34 from rhodecode.lib.compat import OrderedDict
35 from rhodecode.lib.datelib import (
35 from rhodecode.lib.datelib import (
36 date_fromtimestamp, makedate, date_to_timestamp_plus_offset,
36 utcdate_fromtimestamp, makedate, date_astimestamp)
37 date_astimestamp)
38 from rhodecode.lib.utils import safe_unicode, safe_str
37 from rhodecode.lib.utils import safe_unicode, safe_str
39 from rhodecode.lib.vcs import connection
38 from rhodecode.lib.vcs import connection
40 from rhodecode.lib.vcs.backends.base import (
39 from rhodecode.lib.vcs.backends.base import (
@@ -368,7 +367,7 b' class MercurialRepository(BaseRepository'
368 Returns last change made on this repository as
367 Returns last change made on this repository as
369 `datetime.datetime` object
368 `datetime.datetime` object
370 """
369 """
371 return date_fromtimestamp(self._get_mtime(), makedate()[1])
370 return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
372
371
373 def _get_mtime(self):
372 def _get_mtime(self):
374 try:
373 try:
General Comments 0
You need to be logged in to leave comments. Login now