本文整理汇总了Python中vistrails.core.system.time_strptime函数的典型用法代码示例。如果您正苦于以下问题:Python time_strptime函数的具体用法?Python time_strptime怎么用?Python time_strptime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了time_strptime函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convertFromStr
def convertFromStr(self, value, type):
if value is not None:
if type == 'str':
return str(value)
elif value.strip() != '':
if type == 'long':
try:
return long(value)
except ValueError:
return -1
elif type == 'float':
return float(value)
elif type == 'int':
try:
return int(value)
except ValueError:
if 'False' == value:
return -1
else:
return 0
elif type == 'date':
return date(*time_strptime(value, '%Y-%m-%d')[0:3])
elif type == 'datetime':
return datetime(*time_strptime(value, '%Y-%m-%d %H:%M:%S')[0:6])
return None
示例2: convert_from_str
def convert_from_str(value,type):
def bool_conv(x):
s = str(x).upper()
if s == 'TRUE':
return True
if s == 'FALSE':
return False
if value is not None:
if type == 'str':
return str(value)
elif value.strip() != '':
if type == 'long':
return long(value)
elif type == 'float':
return float(value)
elif type == 'int':
return int(value)
elif type == 'bool':
return bool_conv(value)
elif type == 'date':
return date(*time_strptime(value, '%Y-%m-%d')[0:3])
elif type == 'datetime':
return datetime(*time_strptime(value, '%Y-%m-%d %H:%M:%S')[0:6])
return None
示例3: convertFromStr
def convertFromStr(self, value, type):
if value is not None:
if type == "str":
return str(value)
elif value.strip() != "":
if type == "long":
return long(value)
elif type == "float":
return float(value)
elif type == "int":
return int(value)
elif type == "date":
return date(*time_strptime(value, "%Y-%m-%d")[0:3])
elif type == "datetime":
return datetime(*time_strptime(value, "%Y-%m-%d %H:%M:%S")[0:6])
return None
示例4: get_db_modification_time
def get_db_modification_time(self, obj_type=None):
if obj_type is None:
if self.obj_type is None:
obj_type = DBVistrail.vtType
else:
obj_type = self.obj_type
ts = io.get_db_object_modification_time(self.get_connection(),
self.obj_id,
obj_type)
ts = datetime(*time_strptime(str(ts).strip(), '%Y-%m-%d %H:%M:%S')[0:6])
return ts
示例5: convertFromDB
def convertFromDB(self, value, type, db_type):
if value is not None:
if type == "str":
return str(value)
elif type == "long":
return long(value)
elif type == "float":
return float(value)
elif type == "int":
return int(value)
elif type == "date":
if db_type == "date":
return value
else:
return date(*time_strptime(str(value), "%Y-%m-%d")[0:3])
elif type == "datetime":
if db_type == "datetime":
return value
else:
return datetime(*time_strptime(str(value), "%Y-%m-%d %H:%M:%S")[0:6])
return None
示例6: convertFromDB
def convertFromDB(self, value, type, db_type):
if value is not None:
if type == 'str':
return str(value)
elif type == 'long':
return long(value)
elif type == 'float':
return float(value)
elif type == 'int':
return int(value)
elif type == 'date':
if db_type == 'date':
return value
else:
return date(*time_strptime(str(value), '%Y-%m-%d')[0:3])
elif type == 'datetime':
if db_type == 'datetime':
return value
else:
return datetime(*time_strptime(str(value),
'%Y-%m-%d %H:%M:%S')[0:6])
return None
示例7: _convert_value_node
def _convert_value_node(self, node):
"""Convert a 'value' node (i.e. anything but 'key') into a Python data
structure"""
if node.tag == 'string':
return self._content(node)
elif node.tag == 'integer':
return int(self._content(node))
elif node.tag == 'real':
return float(self._content(node))
elif node.tag == 'date': # <date>2004-07-05T13:29:29Z</date>
return datetime.datetime(
*time_strptime(self._content(node), '%Y-%m-%dT%H:%M:%SZ')[:5])
elif node.tag == 'array':
return [self._convert_value_node(n) for n in node.getchildren()]
elif node.tag == 'dict':
return dict([(self._content(n), self._convert_value_node(m))
for n, m in group(node.getchildren(), 2)])
else:
raise ValueError(node.tag)
示例8: match
def match(self, vistrail, action):
if not action.date:
return False
t = time.mktime(time_strptime(action.date, "%d %b %Y %H:%M:%S"))
return t >= self.date
示例9: _set_date
def _set_date(self, date):
if isinstance(date, datetime):
self.db_date = date
elif isinstance(date, basestring) and date.strip() != '':
newDate = datetime(*time_strptime(date, '%d %b %Y %H:%M:%S')[0:6])
self.db_date = newDate
示例10: convertDate
def convertDate(date):
if date is not None and date != '':
return datetime(*time_strptime(date, '%d %b %Y %H:%M:%S')[0:6])
return datetime(1900, 1, 1)
示例11: match
def match(self, entity):
if not entity.mod_time:
return False
t = time.mktime(time_strptime(entity.mod_time, "%d %b %Y %H:%M:%S"))
return t >= self.date
示例12: match
def match(self, controller, action):
if not action.date:
return False
t = time.mktime(time_strptime(action.date, "%d %b %Y %H:%M:%S"))
return t <= self.date