tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends
This commit is contained in:
parent
d36f76e7d3
commit
0242772939
4 changed files with 21 additions and 17 deletions
|
|
@ -24,6 +24,7 @@ from sat.core.log import getLogger
|
|||
log = getLogger(__name__)
|
||||
from sat.tools import utils
|
||||
from sat.tools.common import uri as uri_parse
|
||||
from sat.tools.common import date_utils
|
||||
from twisted.internet import defer
|
||||
from twisted.words.protocols.jabber import jid, error
|
||||
from twisted.words.xish import domish
|
||||
|
|
@ -111,7 +112,7 @@ class Events(object):
|
|||
raise exceptions.NotFound(_(u"No event with this id has been found"))
|
||||
|
||||
try:
|
||||
timestamp = utils.date_parse(next(event_elt.elements(NS_EVENT, "date")))
|
||||
timestamp = date_utils.date_parse(next(event_elt.elements(NS_EVENT, "date")))
|
||||
except StopIteration:
|
||||
timestamp = -1
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from sat.core import exceptions
|
|||
from sat.core.constants import Const as C
|
||||
from sat.tools import xml_tools
|
||||
from sat.tools import utils
|
||||
from sat.tools.common import date_utils
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.words.protocols.jabber.xmlstream import XMPPHandler
|
||||
from twisted.internet import defer
|
||||
|
|
@ -353,7 +354,7 @@ class PubsubSchema(object):
|
|||
return widget_type, args, kwargs
|
||||
# we convert XMPP date to timestamp
|
||||
try:
|
||||
args[0] = unicode(utils.date_parse(args[0]))
|
||||
args[0] = unicode(date_utils.date_parse(args[0]))
|
||||
except Exception as e:
|
||||
log.warning(_(u"Can't parse date field: {msg}").format(msg=e))
|
||||
return widget_type, args, kwargs
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from sat.core import exceptions
|
|||
from twisted.internet import defer
|
||||
import os.path
|
||||
from lxml import etree
|
||||
from sat.tools import utils
|
||||
from sat.tools.common import date_utils
|
||||
|
||||
|
||||
PLUGIN_INFO = {
|
||||
|
|
@ -68,8 +68,8 @@ class BugzillaParser(object):
|
|||
for bug in root.xpath('bug'):
|
||||
ticket = {}
|
||||
ticket['id'] = bug.findtext('bug_id')
|
||||
ticket['created'] = utils.date_parse(bug.findtext('creation_ts'))
|
||||
ticket['updated'] = utils.date_parse(bug.findtext('delta_ts'))
|
||||
ticket['created'] = date_utils.date_parse(bug.findtext('creation_ts'))
|
||||
ticket['updated'] = date_utils.date_parse(bug.findtext('delta_ts'))
|
||||
ticket['title'] = bug.findtext('short_desc')
|
||||
reporter_elt = bug.find('reporter')
|
||||
ticket['author'] = reporter_elt.get('name')
|
||||
|
|
@ -103,7 +103,7 @@ class BugzillaParser(object):
|
|||
who = longdesc.find('who')
|
||||
comment = {'id': longdesc.findtext('commentid'),
|
||||
'author_email': who.text,
|
||||
'published': utils.date_parse(longdesc.findtext('bug_when')),
|
||||
'published': date_utils.date_parse(longdesc.findtext('bug_when')),
|
||||
'author': who.get('name', who.text),
|
||||
'content': longdesc.findtext('thetext')}
|
||||
comments.append(comment)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ from wokkel import disco, iwokkel
|
|||
from zope.interface import implements
|
||||
from sat.tools import utils
|
||||
from sat.tools import stream
|
||||
from sat.tools.common import date_utils
|
||||
import os.path
|
||||
from twisted.words.xish import domish
|
||||
from twisted.words.protocols.jabber import jid
|
||||
|
|
@ -210,7 +211,7 @@ class XEP_0234(object):
|
|||
pass
|
||||
|
||||
try:
|
||||
file_data[u'modified'] = utils.date_parse(next(file_elt.elements(NS_JINGLE_FT, u'date')))
|
||||
file_data[u'modified'] = date_utils.date_parse(next(file_elt.elements(NS_JINGLE_FT, u'date')))
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue