import {ApiCall} from "tsrpc";
import {ReqGetStatus, ResGetStatus} from "../../shared/protocols/hbzb/PtlGetStatus";
import {PublicShared} from "../../shared/public/public";
import {re} from "mathjs";

export default async function (call: ApiCall<ReqGetStatus, ResGetStatus>) {

    let jfs = G.gc.hbzb.jfsOpenTime
    let zbs = G.gc.hbzb.zbsOpenTime

    let zeroTime = PublicShared.getToWeekMondayZeroTime()

    if ((jfs[0] + zeroTime) < G.time && G.time < (jfs[1] + zeroTime)) {
        return call.succ({type: 1, endTime: jfs[1] + zeroTime})
    }

    if ((zbs[0] + zeroTime) < G.time && G.time < (zbs[1] + zeroTime)) {
        return call.succ({type: 2, endTime: zbs[1] + zeroTime})
    }

    return call.succ({type: 3});
}