vcs: make commit datetimes utc

This commit is contained in:
Daniel Dourvaris 2016-06-09 05:20:58 +03:00
parent 1255a47820
commit bf510fd33c
5 changed files with 12 additions and 13 deletions

View file

@ -35,7 +35,7 @@ def makedate():
return time.mktime(lt), tz
def date_fromtimestamp(unixts, tzoffset=0):
def utcdate_fromtimestamp(unixts, tzoffset=0):
"""
Makes a local datetime object out of unix timestamp
@ -43,7 +43,7 @@ def date_fromtimestamp(unixts, tzoffset=0):
:param tzoffset:
"""
return datetime.datetime.fromtimestamp(float(unixts))
return datetime.datetime.utcfromtimestamp(float(unixts))
def date_astimestamp(value):

View file

@ -30,7 +30,7 @@ from StringIO import StringIO
from zope.cachedescriptors.property import Lazy as LazyProperty
from rhodecode.lib.datelib import date_fromtimestamp
from rhodecode.lib.datelib import utcdate_fromtimestamp
from rhodecode.lib.utils import safe_unicode, safe_str
from rhodecode.lib.utils2 import safe_int
from rhodecode.lib.vcs.conf import settings
@ -95,7 +95,7 @@ class GitCommit(base.BaseCommit):
if value:
value = safe_unicode(value)
elif attr == "date":
value = date_fromtimestamp(*value)
value = utcdate_fromtimestamp(*value)
elif attr == "parents":
value = self._make_commits(value)
self.__dict__[attr] = value
@ -135,7 +135,7 @@ class GitCommit(base.BaseCommit):
def date(self):
unix_ts, tz = self._remote.get_object_attrs(
self.raw_id, self._date_property, self._date_tz_property)
return date_fromtimestamp(unix_ts, tz)
return utcdate_fromtimestamp(unix_ts, tz)
@LazyProperty
def status(self):

View file

@ -31,7 +31,7 @@ import time
from zope.cachedescriptors.property import Lazy as LazyProperty
from rhodecode.lib.compat import OrderedDict
from rhodecode.lib.datelib import makedate, date_fromtimestamp
from rhodecode.lib.datelib import makedate, utcdate_fromtimestamp
from rhodecode.lib.utils import safe_unicode, safe_str
from rhodecode.lib.vcs import connection, path as vcspath
from rhodecode.lib.vcs.backends.base import (
@ -269,7 +269,7 @@ class GitRepository(BaseRepository):
Returns last change made on this repository as
`datetime.datetime` object.
"""
return date_fromtimestamp(self._get_mtime(), makedate()[1])
return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
def _get_mtime(self):
try:

View file

@ -26,7 +26,7 @@ import os
from zope.cachedescriptors.property import Lazy as LazyProperty
from rhodecode.lib.datelib import date_fromtimestamp
from rhodecode.lib.datelib import utcdate_fromtimestamp
from rhodecode.lib.utils import safe_str, safe_unicode
from rhodecode.lib.vcs import path as vcspath
from rhodecode.lib.vcs.backends import base
@ -78,7 +78,7 @@ class MercurialCommit(base.BaseCommit):
elif attr == "affected_files":
value = map(safe_unicode, value)
elif attr == "date":
value = date_fromtimestamp(*value)
value = utcdate_fromtimestamp(*value)
elif attr in ["children", "parents"]:
value = self._make_commits(value)
self.__dict__[attr] = value
@ -114,7 +114,7 @@ class MercurialCommit(base.BaseCommit):
@LazyProperty
def date(self):
return date_fromtimestamp(*self._remote.ctx_date(self.idx))
return utcdate_fromtimestamp(*self._remote.ctx_date(self.idx))
@LazyProperty
def status(self):

View file

@ -33,8 +33,7 @@ from zope.cachedescriptors.property import Lazy as LazyProperty
from rhodecode.lib.compat import OrderedDict
from rhodecode.lib.datelib import (
date_fromtimestamp, makedate, date_to_timestamp_plus_offset,
date_astimestamp)
utcdate_fromtimestamp, makedate, date_astimestamp)
from rhodecode.lib.utils import safe_unicode, safe_str
from rhodecode.lib.vcs import connection
from rhodecode.lib.vcs.backends.base import (
@ -368,7 +367,7 @@ class MercurialRepository(BaseRepository):
Returns last change made on this repository as
`datetime.datetime` object
"""
return date_fromtimestamp(self._get_mtime(), makedate()[1])
return utcdate_fromtimestamp(self._get_mtime(), makedate()[1])
def _get_mtime(self):
try: