From c42425467045f5bf67cb98835dc55994f711d7a0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 23 Aug 2023 13:50:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0get=5Fday=5Fs?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/services.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/enm/services.py b/apps/enm/services.py index c1a344ab..b8931054 100644 --- a/apps/enm/services.py +++ b/apps/enm/services.py @@ -3,6 +3,7 @@ import re import traceback from apps.mtm.services import get_mgroup_goals from django.db.models import Q +import datetime def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: int): @@ -19,6 +20,17 @@ def translate_eval_formula(exp_str: str, year: int, month: int, day: int, hour: return rval +def get_day_s(year: int, month: int, day: int, hour: int, hour_split: int = 21): + """ + 根据给定的小时数, 计算出班天 + """ + if hour <= hour_split: + return year, month, day + else: + now = datetime.datetime(year, month, day, hour) + now2 = now + datetime.timedelta(days=1) + return now2.year, now2.month, now2.day + # cal_rule = { # "电石渣": { # "total_production": 0.4,