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
1 changed files with 21 additions and 17 deletions
|
|
@ -25,10 +25,8 @@ from sat.core.constants import Const as C
|
|||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
import datetime
|
||||
from dateutil import parser as dateutil_parser
|
||||
from twisted.python import procutils
|
||||
import subprocess
|
||||
import calendar
|
||||
import time
|
||||
import sys
|
||||
import random
|
||||
|
|
@ -91,14 +89,6 @@ def xmpp_date(timestamp=None, with_time=True):
|
|||
template = u"{}T{}".format(template_date, template_time) if with_time else template_date
|
||||
return datetime.datetime.utcfromtimestamp(time.time() if timestamp is None else timestamp).strftime(template)
|
||||
|
||||
def date_parse(value):
|
||||
"""Parse a date and return corresponding unix timestamp
|
||||
|
||||
@param value(unicode): date to parse, in any format supported by dateutil.parser
|
||||
@return (int): timestamp
|
||||
"""
|
||||
return calendar.timegm(dateutil_parser.parse(unicode(value)).utctimetuple())
|
||||
|
||||
def generatePassword(vocabulary=None, size=20):
|
||||
"""Generate a password with random characters.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue