Mercurial > libervia-backend
comparison sat/plugins/plugin_exp_pubsub_schema.py @ 2612:3e4e78de9cca
tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 21 Jun 2018 01:21:44 +0200 |
parents | 5d4ac5415b40 |
children | 56f94936df1e |
comparison
equal
deleted
inserted
replaced
2611:c180ca699e72 | 2612:3e4e78de9cca |
---|---|
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core import exceptions | 21 from sat.core import exceptions |
22 from sat.core.constants import Const as C | 22 from sat.core.constants import Const as C |
23 from sat.tools import xml_tools | 23 from sat.tools import xml_tools |
24 from sat.tools import utils | 24 from sat.tools import utils |
25 from sat.tools.common import date_utils | |
25 from twisted.words.protocols.jabber import jid | 26 from twisted.words.protocols.jabber import jid |
26 from twisted.words.protocols.jabber.xmlstream import XMPPHandler | 27 from twisted.words.protocols.jabber.xmlstream import XMPPHandler |
27 from twisted.internet import defer | 28 from twisted.internet import defer |
28 from sat.core.log import getLogger | 29 from sat.core.log import getLogger |
29 log = getLogger(__name__) | 30 log = getLogger(__name__) |
351 """Convert a string with a date to a unix timestamp""" | 352 """Convert a string with a date to a unix timestamp""" |
352 if widget_type != u'string' or not args[0]: | 353 if widget_type != u'string' or not args[0]: |
353 return widget_type, args, kwargs | 354 return widget_type, args, kwargs |
354 # we convert XMPP date to timestamp | 355 # we convert XMPP date to timestamp |
355 try: | 356 try: |
356 args[0] = unicode(utils.date_parse(args[0])) | 357 args[0] = unicode(date_utils.date_parse(args[0])) |
357 except Exception as e: | 358 except Exception as e: |
358 log.warning(_(u"Can't parse date field: {msg}").format(msg=e)) | 359 log.warning(_(u"Can't parse date field: {msg}").format(msg=e)) |
359 return widget_type, args, kwargs | 360 return widget_type, args, kwargs |
360 | 361 |
361 ## Helper methods ## | 362 ## Helper methods ## |