本文整理汇总了Python中tinyms.core.common.Utils.format_time方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.format_time方法的具体用法?Python Utils.format_time怎么用?Python Utils.format_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyms.core.common.Utils
的用法示例。
在下文中一共展示了Utils.format_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_timeblocks
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_time [as 别名]
def list_timeblocks():
sf = SessionFactory.new()
rows = sf.query(ValidWorkTimeBlock.id, ValidWorkTimeBlock.name, ValidWorkTimeBlock.start_time,
ValidWorkTimeBlock.end_time).all()
items = list()
for row in rows:
items.append((row[0], row[1], Utils.format_time(row[2]), Utils.format_time(row[3])))
return items
示例2: before_add
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_time [as 别名]
def before_add(self, entity_obj, sf, req):
num = sf.query(func.count(ValidWorkTimeBlock.id)).filter(ValidWorkTimeBlock.name == entity_obj.name).scalar()
if num > 0:
return "名称已经存在!"
num = sf.query(func.count(ValidWorkTimeBlock.id)) \
.filter(cast(ValidWorkTimeBlock.start_time, Time) == Utils.format_time(entity_obj.start_time)) \
.filter(cast(ValidWorkTimeBlock.end_time, Time) == Utils.format_time(entity_obj.end_time)).scalar()
if num > 0:
return "班次/时间段已经存在!"
return ""
示例3: list
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_time [as 别名]
def list(self, search_text, start, limit, http_req):
current_date = None
if not current_date:
current_date = Utils.format_date(Utils.current_datetime())
sf = SessionFactory.new()
subq = sf.query(Term.name.label("term_name"), TermTaxonomy.id).filter(TermTaxonomy.term_id == Term.id).subquery()
q = sf.query(ValidWorkCheckOn.id,
Archives.code,
Archives.name,
ValidWorkTimeBlock.name,
ValidWorkTimeBlock.start_time,
ValidWorkTimeBlock.end_time,
ValidWorkCheckOn.status_in,
ValidWorkCheckOn.status_out,
ValidWorkCheckOn.status_no_sign,
ValidWorkCheckOn.check_in_time,
ValidWorkCheckOn.check_out_time,
subq.c.term_name,
MinuteDiff(ValidWorkCheckOn.valid_start_time, ValidWorkCheckOn.valid_end_time).label("diff")
).select_from(ValidWorkCheckOn)\
.join(ValidWorkTimeBlock, ValidWorkCheckOn.time_block_id == ValidWorkTimeBlock.id)\
.join(Archives, ValidWorkCheckOn.archives_id == Archives.id)\
.outerjoin(subq, subq.c.id == Archives.org_id)
if search_text:
q = q.filter(Archives.name.contains(search_text))
q = q.order_by(Archives.name).filter(cast(ValidWorkCheckOn.valid_start_time, Date) == current_date)
ds = q.offset(start).limit(limit).all()
items = list()
for row in ds:
obj = EmptyClass()
obj.id = row[0]
obj.code = row[1]
obj.name = row[2]
obj.tb_name = row[3]
obj.start_time = Utils.format_time(row[4])
obj.end_time = Utils.format_time(row[5])
obj.status_in = row[6]
obj.status_out = row[7]
obj.status_no_sign = row[8]
obj.check_in_time = Utils.format_time(row[9])
obj.check_out_time = Utils.format_time(row[10])
obj.org_name = row[11]
obj.no_work_timediff = row[12]
items.append(obj.__dict__)
return items