import datetime

from unitls.LogerinTxt import app_logger


def judge_bc():
    try:
        nowDay = datetime.date.today().strftime("%Y%m%d")
        nowDay_1 = (datetime.date.today() - datetime.timedelta(days=1)).strftime("%Y%m%d")
        #nowDay_2 = (datetime.date.today() + datetime.timedelta(days=1)).strftime("%Y%m%d")
        nowDay_str2 = datetime.date.today().strftime("%Y-%m-%d")
        a_str = nowDay_str2 + " 09:00:00"
        b_str = nowDay_str2 + " 20:30:00"
        a = datetime.datetime.strptime(a_str, "%Y-%m-%d %H:%M:%S")
        b = datetime.datetime.strptime(b_str, "%Y-%m-%d %H:%M:%S")
        nowtime = datetime.datetime.now()
        if a < nowtime < b:
            date=nowDay
            bc="A"
        elif b <= nowtime:
            date = nowDay
            bc = "B"
        else:
            date = nowDay_1
            bc = "B"
        dic={"date":"%s"%date,"bc":"%s"%bc}
        return dic
    except Exception as e:
        app_logger.log_error(e)