本文整理汇总了Python中tinyms.core.common.Utils.format_date方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.format_date方法的具体用法?Python Utils.format_date怎么用?Python Utils.format_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyms.core.common.Utils
的用法示例。
在下文中一共展示了Utils.format_date方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_date [as 别名]
def list(self, kw, start, limit, http_req):
sf = SessionFactory.new()
subq = sf.query(Archives.id, Archives.name).subquery()
q = sf.query(ValidWorkAskForLeave, Archives.name, subq.c.name.label("creator"))\
.join(Archives, ValidWorkAskForLeave.archives_id == Archives.id)\
.outerjoin(subq, ValidWorkAskForLeave.creator == subq.c.id)
if kw:
q = q.filter(Archives.name.contains(kw))
dataset = q.order_by(ValidWorkAskForLeave.id.desc()).offset(start).limit(limit).all()
items = list()
for row in dataset:
ot = row[0]
name = row[1]
creator = row[2]
item = dict()
item["id"] = ot.id
item["kind"] = ot.kind
item["ask_date"] = Utils.format_date(ot.ask_date)
item["start_datetime"] = Utils.format_datetime_short(ot.start_datetime)
item["end_datetime"] = Utils.format_datetime_short(ot.end_datetime)
item["create_datetime"] = Utils.format_datetime_short(ot.create_datetime)
item["name"] = name
item["creator"] = creator
items.append(item)
return items
示例2: count
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_date [as 别名]
def count(self, search_text, 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(func.count(ValidWorkCheckOn.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.filter(cast(ValidWorkCheckOn.valid_start_time, Date) == current_date)
return q.scalar()
示例3: get
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_date [as 别名]
def get(self, *args, **kwargs):
current_date = Utils.format_date(Utils.current_datetime())+" 00:00"
opt = dict()
opt["current_date"] = current_date
return self.render("validwork/overtime.html", context=opt)
示例4: organization_of_work
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import format_date [as 别名]
def organization_of_work():
current_datetime = Utils.current_datetime()
#是否为法定节日
isholiday = ValidWorkSchedulerThread.is_holiday(Utils.format_date(current_datetime))
if isholiday:
return
sf = SessionFactory.new()
#标识-1的状态为旷工,这种情况是没有按指纹的,CheckOn 有效时间段结束时间已经过期的时候
updates = sf.query(ValidWorkCheckOn) \
.filter(or_(ValidWorkCheckOn.status_in == -1, ValidWorkCheckOn.status_out == -1)) \
.filter(ValidWorkCheckOn.valid_end_time < Utils.format_datetime(current_datetime)).all()
for row in updates:
row.status_no_sign = 1
sf.commit()
#列出所有考勤计划
tasks = sf.query(ValidWorkScheduleTask.id).all()
tasks = [task[0] for task in tasks]
for task_id in tasks:
#得到班次最小的时间点
#min_time = sf.query(ValidWorkTimeBlock.start_time) \
# .join(ValidWorkScheduleTask, ValidWorkTimeBlock.validworkscheduletasks) \
# .order_by(asc(ValidWorkTimeBlock.start_time)) \
# .filter(ValidWorkScheduleTask.id == task_id).limit(1).scalar()
#if min_time:
# #提前30分钟安排下一档工作
# min_datetime = datetime.combine(current_datetime.date(), min_time)
# start_datetime = min_datetime - timedelta(minutes=30)
# if start_datetime <= current_datetime <= min_datetime:
#当天是否已经安排完成
e = sf.query(func.count(ValidWorkCheckOn.id)) \
.filter(ValidWorkCheckOn.task_id == task_id) \
.filter(cast(ValidWorkCheckOn.valid_start_time, Date) == Utils.format_date(current_datetime)).scalar()
if e == 0:
#安排新的工作
#1,得到拥有此考勤计划的所有人员ID
usrs = sf.query(Archives.id).join(ValidWorkScheduleTask, Archives.validworkscheduletasks) \
.filter(ValidWorkScheduleTask.id == task_id).all()
usrs = [u[0] for u in usrs]
#2,得到此考勤计划的所有班次
time_blocks = sf.query(ValidWorkTimeBlock) \
.join(ValidWorkScheduleTask, ValidWorkTimeBlock.validworkscheduletasks) \
.filter(ValidWorkScheduleTask.id == task_id).all()
#3,批量插入CheckOn
workers_tb = list()
for usr_id in usrs:
for tb in time_blocks:
vwco = ValidWorkCheckOn()
vwco.archives_id = usr_id
vwco.task_id = task_id
vwco.time_block_id = tb.id
start = datetime.combine(current_datetime.date(), tb.start_time)
end = datetime.combine(current_datetime.date(), tb.end_time)
start = start - timedelta(minutes=tb.normal_in_space)
end = end + timedelta(minutes=tb.normal_out_space)
vwco.valid_start_time = start
vwco.valid_end_time = end
workers_tb.append(vwco)
pass
pass
pass
sf.add_all(workers_tb)
sf.commit()
pass
pass
pass