def deal_confirm_out(account_id, create_time, callback): """ will be linked with the calendar internally, Check out time of registered user. Check also: attendance_management_bot/externals/calendar_req.py :param account_id: user account id. :param create_time: current date by local time. :param callback: The message content of the callback, include the user's check-out time :return: Prompt message of successful check out. """ pos = callback.find("time=") str_time = callback[pos + 5:] user_time = int(str_time) end_time = local_date_time(user_time) current_date = datetime.strftime(end_time, '%Y-%m-%d') info = get_schedule_by_user(account_id, current_date) if info is None: raise HTTPError(500, "Internal data error") schedule_id = info[0] begin_time_st = info[1] cur_time = local_date_time(create_time) begin_time = local_date_time(begin_time_st) fmt = _("{account}'s working hours on {date}") fmt1 = _("%A, %B %d") title = get_i18n_content_by_lang( fmt, "confirm_out", DEFAULT_LANG, fmt1=fmt1, account=get_user_info_by_account(account_id), date=end_time) modify_schedule(schedule_id, cur_time, end_time, begin_time, account_id, title) modify_schedule_by_user(schedule_id, user_time) hours = int((user_time - begin_time_st) / 3600) min = int(((user_time - begin_time_st) % 3600) / 60) return [confirm_out_message(user_time, hours, min)]
def deal_confirm_out(account_id, create_time, callback): """ will be linked with the calendar internally, Check out time of registered user. Check also: attendance_management_bot/externals/calendar_req.py :param account_id: user account id. :param create_time: current date by local time. :param callback: The message content of the callback, include the user's check-out time :return: Prompt message of successful check out. """ pos = callback.find("time=") str_time = callback[pos+5:] user_time = int(str_time) end_time = local_date_time(user_time) current_date = datetime.strftime(end_time, '%Y-%m-%d') info = get_schedule_by_user(account_id, current_date) if info is None: raise HTTPError(500, "Internal data error") schedule_id = info[0] begin_time_st = info[1] cur_time = local_date_time(create_time) begin_time = local_date_time(begin_time_st) title = "[{account}]'s working hours on {date}".\ format(account=get_user_info_by_account(account_id), date=datetime.strftime(end_time, '%A, %B %d')) modify_schedule(schedule_id, cur_time, end_time, begin_time, account_id, title) modify_schedule_by_user(schedule_id, user_time) if user_time < begin_time_st: yield asyncio.sleep(1) set_status_by_user_date(account_id, current_date, status="wait_out") return number_message(), False hours = int((user_time - begin_time_st)/3600) min = int(((user_time - begin_time_st) % 3600)/60) return [confirm_out_message(user_time, hours, min)], True